image.png

FIN: 1 bit

  1. Indicates that this is the final fragment in a message. The first<br /> fragment MAY also be the final fragment.

RSV1, RSV2, RSV3: 1 bit each

  1. MUST be 0 unless an extension is negotiated that defines meanings<br /> for non-zero values. If a nonzero value is received and none of<br /> the negotiated extensions defines the meaning of such a nonzero<br /> value, the receiving endpoint MUST _Fail the WebSocket<br /> Connection_.

Opcode: 4 bits

  1. Defines the interpretation of the "Payload data". If an unknown<br /> opcode is received, the receiving endpoint MUST _Fail the<br /> WebSocket Connection_. The following values are defined.
  2. * %x0 denotes a continuation frame
  3. * %x1 denotes a text frame
  4. * %x2 denotes a binary frame
  5. * %x3-7 are reserved for further non-control frames
  6. * %x8 denotes a connection close
  7. * %x9 denotes a ping
  8. * %xA denotes a pong
  9. * %xB-F are reserved for further control frames

Mask: 1 bit

  1. Defines whether the "Payload data" is masked. If set to 1, a<br /> masking key is present in masking-key, and this is used to unmask<br /> the "Payload data" as per [Section 5.3](https://tools.ietf.org/html/rfc6455#section-5.3). All frames sent from<br /> client to server have this bit set to 1.

Payload length: 7 bits, 7+16 bits, or 7+64 bits

  1. The length of the "Payload data", in bytes: if 0-125, that is the<br /> payload length. If 126, the following 2 bytes interpreted as a<br /> 16-bit unsigned integer are the payload length. If 127, the<br /> following 8 bytes interpreted as a 64-bit unsigned integer (the<br /> most significant bit MUST be 0) are the payload length. Multibyte<br /> length quantities are expressed in network byte order. Note that<br /> in all cases, the minimal number of bytes MUST be used to encode<br /> the length, for example, the length of a 124-byte-long string<br /> can't be encoded as the sequence 126, 0, 124. The payload length<br /> is the length of the "Extension data" + the length of the<br /> "Application data". The length of the "Extension data" may be<br /> zero, in which case the payload length is the length of the<br /> "Application data".

参考