Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Format a Close Frame.

Files

http-c.h/http-c.c

Prototype

Arguments

close_code

Close code to format in the Close message.

p_reason

Pointer to a string to be concatenated to the Close code in the Close message.

p_buf

Pointer to the buffer to set the formatted Close Message.

buf_len

Length of the buffer.

p_err

Pointer to variable that will receive the return error code from this function:

HTTPc_ERR_NONE
HTTPc_ERR_NULL_PTR
HTTPc_ERR_WEBSOCK_INVALID_CLOSE_CODE
HTTPc_ERR_WEBSOCK_INVALID_CTRL_FRAME_LEN

Returned Values

Return the length of the formatted message in the buffer.

Required Configuration

None.

Notes / Warnings

  • This function MUST be called after the µC/HTTP-client Suite Initialization has been completed.
  • Close Frame have a specific format. According to the RFC 6455 section :"If there is a body, the first two bytes of the body MUST be a 2-byte unsigned integer (in network byte order) representing a status code with value /code/ defined in Section 7.4. Following the 2-byte integer,the body MAY contain UTF-8-encoded data with value /reason/, the interpretation of which is not defined by this specification."

  • Close Codes available:

HTTPc_WEBSOCK_CLOSE_CODE_PROTOCOL_ERR
HTTPc_WEBSOCK_CLOSE_CODE_DATA_TYPE_NOT_ALLOWED
HTTPc_WEBSOCK_CLOSE_CODE_DATA_TYPE_ERR
HTTPc_WEBSOCK_CLOSE_CODE_UNEXPECTED_CONDITION 
HTTPc_WEBSOCK_CLOSE_CODE_INVALID_EXT
HTTPc_WEBSOCK_CLOSE_CODE_MSG_TOO_BIG
HTTPc_WEBSOCK_CLOSE_CODE_POLICY_VIOLATION
HTTPc_WEBSOCK_CLOSE_CODE_GOING_AWAY
HTTPc_WEBSOCK_CLOSE_CODE_NORMAL

  • Close Reason: 

    • Except for its length, the reason string has no restriction and it is user-definable. This should be used for debug purpose.

    • This field can be empty.

  • No labels