Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

Sec-WebSocket-Version header

BaselineWidely available

The HTTPSec-WebSocket-Versionrequest andresponse header is used in theWebSocket openinghandshake to indicate the WebSocket protocol supported by the client, and the protocol versions supported by the server if it doesnot support the version specified in the request.

The header can only appear once in a request, and specifies the WebSocket version that web application is using.The current version of the protocol at time of writing is 13.The header is automatically added to requests by user agents when aWebSocket connection is established.

The server uses the version to determine if it can understand the protocol.If the server doesn't support the version, or any header in the handshake is not understood or has an incorrect value, the server should send a response with status400 Bad Request and immediately close the socket.It should also includeSec-WebSocket-Version in the400 response, listing the versions that it does support.The versions can be specified in individual headers, or as comma-separate values in a single header.

The header should not be sent in responses if the server understands the version specified by the client.

Header typeResponse header
Forbidden request headerYes (Sec- prefix)

Syntax

Request

http
Sec-WebSocket-Version: <version>

Response (on error only):

http
Sec-WebSocket-Version: <server-supported-versions>

Directives

<version>

The WebSocket protocol version the client wishes to use when communicating with the server.This number should be the most recent version possible listed in theIANA WebSocket Version Number Registry.The most recent final version of the WebSocket protocol is version 13.

<server-supported-versions>

On error, a comma-delineated list of the WebSocket protocol versions supported by the server.The header is not sent in responses if<version> is supported.

Examples

WebSocket opening handshake

The version supported by the client is specified in the originalWebSockethandshake request.For the current protocol, the version is "13", as shown below.

http
GET /chat HTTP/1.1Host: example.com:8000Upgrade: websocketConnection: UpgradeSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==Sec-WebSocket-Version: 13

If the server supports version 13 of the protocol, thenSec-WebSocket-Version will not appear in the response.

Specifications

Specification
The WebSocket Protocol
# section-11.3.5

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp