Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

http-c.h/http-c.c

Prototype

Code Block

          CPU_BOOLEAN HTTPc_WebSockUpgrade (HTTPc_CONN_OBJ        *p_conn_obj,
                                            HTTPc_REQ_OBJ         *p_req_obj,
                                            HTTPc_RESP_OBJ        *p_resp_obj,
                                            HTTPc_WEBSOCK_OBJ     *p_ws_obj,
                                            CPU_CHAR              *p_resource_path,
                                            CPU_INT16U             resource_path_len,
											HTTPc_FLAGS			   flags,
                                            HTTPc_ERR             *p_err)


Arguments

p_conn_obj

Pointer to the HTTPc Connection Object for which to open the socket.

...

  1. Since the WebSocket Upgrade handshake is based on a HTTP request, the connection object p_conn_obj MUST have already established connected to the desired host server. The Connection MUST be initialized has PERSISTENT.

  2. Any HTTP request/response features available can be used during the Websocket Upgrade Request
  3. During a WebSocket Upgrade handshake, the following mandatory header fields are managed by the WebSocket module and MUST NOT be set by the Application:
        Connection
        Upgrade
        Sec-WebSocket-Key
        Sec-WebSocket-Accept
        Sec-WebSocket-Version

  4. During a Websocket Upgrade Handshake, the following optional Header fields can be managed by the Application using the standard HTTPc Request/Response API:
        Sec-WebSocket-Protocol
        Sec-WebSocket-Extensions

  5. If the Websocket Upgrade Handshake is successful, Status Code in the response object should be '101'. This means that the Host server has switched to the Websocket protocol. Otherwise, the response object will TYPICALLY described the reason of the failure.

  6. When the WebSocket Upgrade is completed, any HTTP request is no more allowed and it is not possible to switch the connection protocol to HTTP. However, if a HTTP request is required to be sent by the Application, it SHOULD do one of the following procedure:

    1. Close the current WebSocket Connection by sending a Close Message and open again the HTTP connection.

    2. Open a different HTTP connection with the Host Server.

...