I learned from websocketAPI that websocket can customize sub-protocols. I want to know more about them, but it seems that there are no similar examples on the Internet. I learned from the websocket API that websocket can customize sub-protocols. I want to know more about them, but it seems that there are no similar examples on the Internet. Reply content: subprotocol is only a field in the header.
RFC 6455-The WebSocket Protocol
The WebSocket API
Because the Websocket Protocol provides a packet-based reliable transmission protocol, it is not an application protocol as HTTP, its package does not have the Content-Type field to describe the Content like HTTP. It is a relatively underlying protocol, just like TCP, if you want to use it for communication, you usually need to set a protocol by yourself. Subprotocol can be used as a label for negotiation between the server and the client.
The client can declare its acceptable sub-protocol types during connection. This is the same as the Accept and Accept-Encoding header fields in the HTTP request header. It means that you can Accept or encode files of the type, usually compressed.
Accept: text/html, application/xhtml + xml, application/xml; q = 0.9, image/webp, */*; q = 0.8Accept-Encoding: gzip, deflate, sdch