msgid ""
msgstr ""
"Project-Id-Version: English (Boost Beast Translation (zh_Hans))\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-06-06 23:53+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: English <https://insights.cppalliance.org/weblate/projects/"
"boost-beast-documentation-zh_Hans/doc-qbk-06-websocket-02-handshaking-qbk/"
"en/>\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 2026.5\n"

#. type: section title
#: 10
#, read-only
msgid "Handshaking"
msgstr "Handshaking"

#. type: heading
#: 14
#, read-only
msgid "Client Role"
msgstr "Client Role"

#. type: paragraph
#: 16
#, read-only
msgid ""
"A WebSocket session begins when a client sends the HTTP/1.1 [@https://"
"tools.ietf.org/html/rfc7230#section-6.7 Upgrade] request for [@https://"
"tools.ietf.org/html/rfc6455#section-1.3 WebSocket] on an established "
"connection, and the server sends an appropriate response indicating that the "
"request was accepted and that the connection has been upgraded. The Upgrade "
"request must include the [@https://tools.ietf.org/html/rfc7230#section-5.4 "
"Host] field, and the [@https://tools.ietf.org/html/rfc7230#section-5.3 "
"target] of the resource to request. A typical HTTP Upgrade request created "
"and sent by the implementation will look like this:"
msgstr ""
"A WebSocket session begins when a client sends the HTTP/1.1 [@https://"
"tools.ietf.org/html/rfc7230#section-6.7 Upgrade] request for [@https://"
"tools.ietf.org/html/rfc6455#section-1.3 WebSocket] on an established "
"connection, and the server sends an appropriate response indicating that the "
"request was accepted and that the connection has been upgraded. The Upgrade "
"request must include the [@https://tools.ietf.org/html/rfc7230#section-5.4 "
"Host] field, and the [@https://tools.ietf.org/html/rfc7230#section-5.3 "
"target] of the resource to request. A typical HTTP Upgrade request created "
"and sent by the implementation will look like this:"

#. type: table title
#: 30
#, read-only
msgid "WebSocket HTTP Upgrade Request"
msgstr "WebSocket HTTP Upgrade Request"

#. type: table cell
#: 30
#, read-only
msgctxt "30"
msgid "Wire Format"
msgstr "Wire Format"

#. type: table cell
#: 30
#, read-only
msgctxt "30"
msgid "Description"
msgstr "Description"

#. type: table code
#: 30
#, read-only
msgid ""
"GET / HTTP/1.1\n"
"Host: www.example.com\n"
"Upgrade: websocket\n"
"Connection: upgrade\n"
"Sec-WebSocket-Key: 2pGeTR0DsE4dfZs2pH+8MA==\n"
"Sec-WebSocket-Version: 13\n"
"User-Agent: Boost.Beast/216"
msgstr ""
"GET / HTTP/1.1\n"
"Host: www.example.com\n"
"Upgrade: websocket\n"
"Connection: upgrade\n"
"Sec-WebSocket-Key: 2pGeTR0DsE4dfZs2pH+8MA==\n"
"Sec-WebSocket-Version: 13\n"
"User-Agent: Boost.Beast/216"

#. type: table cell
#: 30
#, read-only
msgid ""
"The host and target parameters become part of the Host field and request-"
"target in the resulting HTTP request. The key is generated by the "
"implementation. Callers who wish to add, modify, or inspect fields may set "
"the ['decorator] option on the stream (described later)."
msgstr ""
"The host and target parameters become part of the Host field and request-"
"target in the resulting HTTP request. The key is generated by the "
"implementation. Callers who wish to add, modify, or inspect fields may set "
"the ['decorator] option on the stream (described later)."

#. type: paragraph
#: 50
#, read-only
msgid ""
"The [link beast.ref.boost__beast__websocket__stream `websocket::stream`] "
"member functions [link beast.ref.boost__beast__websocket__stream.handshake "
"`handshake`] and [link "
"beast.ref.boost__beast__websocket__stream.async_handshake `async_handshake`] "
"are used to send the request with the required host and target strings. This "
"code connects to the IP address returned from a hostname lookup, then "
"performs the WebSocket handshake in the client role."
msgstr ""
"The [link beast.ref.boost__beast__websocket__stream `websocket::stream`] "
"member functions [link beast.ref.boost__beast__websocket__stream.handshake "
"`handshake`] and [link "
"beast.ref.boost__beast__websocket__stream.async_handshake `async_handshake`] "
"are used to send the request with the required host and target strings. This "
"code connects to the IP address returned from a hostname lookup, then "
"performs the WebSocket handshake in the client role."

#. type: paragraph
#: 61
#, read-only
msgid ""
"When a client receives an HTTP Upgrade response from the server indicating a "
"successful upgrade, the caller may wish to perform additional validation on "
"the received HTTP response message. For example, to check that the response "
"to a basic authentication challenge is valid. To achieve this, overloads of "
"the handshake member function allow the caller to store the received HTTP "
"message in an output reference argument of type [link "
"beast.ref.boost__beast__websocket__response_type `response_type`] as follows:"
msgstr ""
"When a client receives an HTTP Upgrade response from the server indicating a "
"successful upgrade, the caller may wish to perform additional validation on "
"the received HTTP response message. For example, to check that the response "
"to a basic authentication challenge is valid. To achieve this, overloads of "
"the handshake member function allow the caller to store the received HTTP "
"message in an output reference argument of type [link "
"beast.ref.boost__beast__websocket__response_type `response_type`] as follows:"

#. type: heading
#: 74
#, read-only
msgid "Server Role"
msgstr "Server Role"

#. type: paragraph
#: 76
#, read-only
msgid ""
"For servers accepting incoming connections, the [link "
"beast.ref.boost__beast__websocket__stream `websocket::stream`] can read the "
"incoming upgrade request and automatically reply. If the handshake meets the "
"requirements, the stream sends back the upgrade response with a [@https://"
"tools.ietf.org/html/rfc6455#section-4.2.2 ['101 Switching Protocols]] status "
"code. If the handshake does not meet the requirements, or falls outside the "
"range of allowed parameters specified by stream options set previously by "
"the caller, the stream sends back an HTTP response with a status code "
"indicating an error. Depending on the keep alive setting, the connection may "
"remain open for a subsequent handshake attempt. A typical HTTP Upgrade "
"response created and sent by the implementation upon receiving an upgrade "
"request handshake will look like this:"
msgstr ""
"For servers accepting incoming connections, the [link "
"beast.ref.boost__beast__websocket__stream `websocket::stream`] can read the "
"incoming upgrade request and automatically reply. If the handshake meets the "
"requirements, the stream sends back the upgrade response with a [@https://"
"tools.ietf.org/html/rfc6455#section-4.2.2 ['101 Switching Protocols]] status "
"code. If the handshake does not meet the requirements, or falls outside the "
"range of allowed parameters specified by stream options set previously by "
"the caller, the stream sends back an HTTP response with a status code "
"indicating an error. Depending on the keep alive setting, the connection may "
"remain open for a subsequent handshake attempt. A typical HTTP Upgrade "
"response created and sent by the implementation upon receiving an upgrade "
"request handshake will look like this:"

#. type: table title
#: 89
#, read-only
msgid "WebSocket Upgrade HTTP Response"
msgstr "WebSocket Upgrade HTTP Response"

#. type: table cell
#: 89
#, read-only
msgctxt "89"
msgid "Wire Format"
msgstr "Wire Format"

#. type: table cell
#: 89
#, read-only
msgctxt "89"
msgid "Description"
msgstr "Description"

#. type: table code
#: 89
#, read-only
msgid ""
"HTTP/1.1 101 Switching Protocols\n"
"Upgrade: websocket\n"
"Connection: upgrade\n"
"Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\n"
"Server: Boost.Beast"
msgstr ""
"HTTP/1.1 101 Switching Protocols\n"
"Upgrade: websocket\n"
"Connection: upgrade\n"
"Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\n"
"Server: Boost.Beast"

#. type: table cell
#: 89
#, read-only
msgid ""
"The [@https://tools.ietf.org/html/rfc6455#section-11.3.3 ['Sec-WebSocket-"
"Accept]] field value is generated from the request in a fashion specified by "
"the WebSocket protocol."
msgstr ""
"The [@https://tools.ietf.org/html/rfc6455#section-11.3.3 ['Sec-WebSocket-"
"Accept]] field value is generated from the request in a fashion specified by "
"the WebSocket protocol."

#. type: paragraph
#: 106
#, read-only
msgid ""
"The [link beast.ref.boost__beast__websocket__stream `stream`] member "
"functions [link beast.ref.boost__beast__websocket__stream.accept `accept`] "
"and [link beast.ref.boost__beast__websocket__stream.async_accept "
"`async_accept`] are used to read the WebSocket HTTP Upgrade request "
"handshake from a stream already connected to an incoming peer, and then send "
"the WebSocket HTTP Upgrade response, as shown:"
msgstr ""
"The [link beast.ref.boost__beast__websocket__stream `stream`] member "
"functions [link beast.ref.boost__beast__websocket__stream.accept `accept`] "
"and [link beast.ref.boost__beast__websocket__stream.async_accept "
"`async_accept`] are used to read the WebSocket HTTP Upgrade request "
"handshake from a stream already connected to an incoming peer, and then send "
"the WebSocket HTTP Upgrade response, as shown:"

#. type: heading
#: 117
#, read-only
msgid "Handshake Buffering"
msgstr "Handshake Buffering"

#. type: paragraph
#: 119
#, read-only
msgid ""
"It is possible for servers to read data from the stream and decide later "
"that the buffered bytes should be interpreted as a WebSocket upgrade "
"request. To address this usage, overloads of [link "
"beast.ref.boost__beast__websocket__stream.accept `accept`] and [link "
"beast.ref.boost__beast__websocket__stream.async_accept `async_accept`] which "
"accept an additional buffer sequence parameter are provided."
msgstr ""
"It is possible for servers to read data from the stream and decide later "
"that the buffered bytes should be interpreted as a WebSocket upgrade "
"request. To address this usage, overloads of [link "
"beast.ref.boost__beast__websocket__stream.accept `accept`] and [link "
"beast.ref.boost__beast__websocket__stream.async_accept `async_accept`] which "
"accept an additional buffer sequence parameter are provided."

#. type: paragraph
#: 126
#, read-only
msgid ""
"In this example, the server reads the initial HTTP request header into a "
"dynamic buffer, then later uses the buffered data to attempt a websocket "
"upgrade."
msgstr ""
"In this example, the server reads the initial HTTP request header into a "
"dynamic buffer, then later uses the buffered data to attempt a websocket "
"upgrade."

#. type: heading
#: 132
#, read-only
msgid "Inspecting HTTP Requests"
msgstr "Inspecting HTTP Requests"

#. type: paragraph
#: 134
#, read-only
msgid ""
"When implementing an HTTP server that also supports WebSocket, the server "
"usually reads the HTTP request from the client. To detect when the incoming "
"HTTP request is a WebSocket Upgrade request, the function [link "
"beast.ref.boost__beast__websocket__is_upgrade `is_upgrade`] may be used."
msgstr ""
"When implementing an HTTP server that also supports WebSocket, the server "
"usually reads the HTTP request from the client. To detect when the incoming "
"HTTP request is a WebSocket Upgrade request, the function [link "
"beast.ref.boost__beast__websocket__is_upgrade `is_upgrade`] may be used."

#. type: paragraph
#: 139
#, read-only
msgid ""
"Once the caller determines that the HTTP request is a WebSocket Upgrade, "
"additional overloads of [link "
"beast.ref.boost__beast__websocket__stream.accept `accept`] and [link "
"beast.ref.boost__beast__websocket__stream.async_accept `async_accept`] are "
"provided which receive the entire HTTP request header as an object to "
"perform the handshake. By reading the request manually, the program can "
"handle normal HTTP requests as well as upgrades. The program may also "
"enforce policies based on the HTTP fields, such as Basic Authentication. In "
"this example, the request is first read in using the HTTP algorithms, and "
"then passed to a newly constructed stream:"
msgstr ""
"Once the caller determines that the HTTP request is a WebSocket Upgrade, "
"additional overloads of [link "
"beast.ref.boost__beast__websocket__stream.accept `accept`] and [link "
"beast.ref.boost__beast__websocket__stream.async_accept `async_accept`] are "
"provided which receive the entire HTTP request header as an object to "
"perform the handshake. By reading the request manually, the program can "
"handle normal HTTP requests as well as upgrades. The program may also "
"enforce policies based on the HTTP fields, such as Basic Authentication. In "
"this example, the request is first read in using the HTTP algorithms, and "
"then passed to a newly constructed stream:"

#. type: heading
#: 153
#, read-only
msgid "Subprotocols"
msgstr "Subprotocols"

#. type: paragraph
#: 155
#, read-only
msgid ""
"The WebSocket protocol understands the concept of subprotocols. If the "
"client is requesting one of a set of subprotocols it will set the header "
"[@https://tools.ietf.org/html/rfc6455#section-11.3.4 Sec-WebSocket-Protocol] "
"in the initial WebSocket Upgrade HTTP request. It is up to the server to "
"parse the header and select one of the protocols to accept. The server "
"indicates the selected protocol by setting the [@https://tools.ietf.org/html/"
"rfc6455#section-11.3.4 Sec-WebSocket-Protocol] header in the accept header."
msgstr ""
"The WebSocket protocol understands the concept of subprotocols. If the "
"client is requesting one of a set of subprotocols it will set the header "
"[@https://tools.ietf.org/html/rfc6455#section-11.3.4 Sec-WebSocket-Protocol] "
"in the initial WebSocket Upgrade HTTP request. It is up to the server to "
"parse the header and select one of the protocols to accept. The server "
"indicates the selected protocol by setting the [@https://tools.ietf.org/html/"
"rfc6455#section-11.3.4 Sec-WebSocket-Protocol] header in the accept header."

#. type: paragraph
#: 164
#, read-only
msgid ""
"This is accomplished with a [link "
"beast.ref.boost__beast__websocket__stream_base__decorator `decorator`]."
msgstr ""
"This is accomplished with a [link "
"beast.ref.boost__beast__websocket__stream_base__decorator `decorator`]."

#. type: paragraph
#: 167
#, read-only
msgid ""
"The code that follows demonstrates how a server reads an HTTP request, "
"identifies it as a WebSocket Upgrade, and then checks for a preferred "
"matching subprotocol before performing the WebSocket handshake:"
msgstr ""
"The code that follows demonstrates how a server reads an HTTP request, "
"identifies it as a WebSocket Upgrade, and then checks for a preferred "
"matching subprotocol before performing the WebSocket handshake:"
