Mstdlib-1.24.0
|
Modules | |
HTTP Stream Reader | |
HTTP Simple | |
Functions | |
M_http_version_t | M_http_version_from_str (const char *version) |
const char * | M_http_version_to_str (M_http_version_t version) |
M_http_method_t | M_http_method_from_str (const char *method) |
const char * | M_http_method_to_str (M_http_method_t method) |
const char * | M_http_code_to_reason (M_uint32 code) |
const char * | M_http_errcode_to_str (M_http_error_t err) |
char * | M_http_generate_query_string (const char *uri, const M_hash_dict_t *params) |
M_bool | M_http_generate_query_string_buf (M_buf_t *buf, const char *uri, const M_hash_dict_t *params) |
M_hash_dict_t * | M_http_parse_query_string (const char *data, M_textcodec_codec_t codec) |
char * | M_http_generate_form_data_string (const M_hash_dict_t *params) |
M_bool | M_http_generate_form_data_string_buf (M_buf_t *buf, const M_hash_dict_t *params) |
M_hash_dict_t * | M_http_parse_form_data_string (const char *data, M_textcodec_codec_t codec) |
HTTP 1.0/1.1 message reading and writing.
Conforms to:
There are two types of message parsing supported.
Currently supported Read:
Currently support Write:
enum M_http_error_t |
Error codes.
M_HTTP_ERROR_SUCCESS, and M_HTTP_ERROR_SUCCESS_MORE_POSSIBLE are both Success conditions. All data is valid and has been parsed.
M_HTTP_ERROR_MOREDATA indicates valid data and isn't always considered an error condition. It typically indicates a retry once more data is received condition. For example more headers could follow or the content length or chucked data was not complete. There is more data needed to complete the message. It is only an error if end of data has been reached.
M_HTTP_ERROR_STOP is not considered an error and means no more processing will/should take place. A callback should generate this if all data the caller wants has been processed if partial processing is taking place. For example, a proxy looking for X-Forwarded-For header in order to blacklist an abusive IP before forwarding the message.
enum M_http_version_t |
enum M_http_method_t |
HTTP methods.
enum M_http_data_format_t |
M_http_version_t M_http_version_from_str | ( | const char * | version | ) |
Convert a version string into a version value.
The version can start with "HTTP/" or without.
[in] | version | Version string. |
const char * M_http_version_to_str | ( | M_http_version_t | version | ) |
Convert an http version to a string.
Returns in the format "HTTP/#".
[in] | version | Version. |
M_http_method_t M_http_method_from_str | ( | const char * | method | ) |
Convert a method string into a method value.
[in] | method | Method string. |
const char * M_http_method_to_str | ( | M_http_method_t | method | ) |
Convert an http method to a string.
[in] | method | Method. |
const char * M_http_code_to_reason | ( | M_uint32 | code | ) |
Convert an http code to a string.
Not all codes can be converted to a string. Codes that cannot be converted will return "Generic".
[in] | code | Code. |
const char * M_http_errcode_to_str | ( | M_http_error_t | err | ) |
Convert an http error code to a string.
[in] | err | Error code. |
char * M_http_generate_query_string | ( | const char * | uri, |
const M_hash_dict_t * | params | ||
) |
Create query string, append to given URI, return as new string.
Empty values are not permitted - keys whose values are set to the empty string will be left out of the query string.
Query string are defined as application/x-www-form-urlencoded data so url form encoding is used.
[in] | uri | Uri string (e.g., /cgi-bin/payment/start, or http://google.com/whatever). |
[in] | params | Key-value pairs to encode in query string. |
NULL
if there was an encoding error. M_bool M_http_generate_query_string_buf | ( | M_buf_t * | buf, |
const char * | uri, | ||
const M_hash_dict_t * | params | ||
) |
Create query string, append URI + query string to buffer.
Empty values are not permitted - keys whose values are set to the empty string will be left out of the query string.
Query string are defined as application/x-www-form-urlencoded data so url form encoding is used.
[out] | buf | Buffer to add URI + query string to, contents remain unchanged if there was an error. |
[in] | uri | Uri string (e.g., /cgi-bin/payment/start, or http://google.com/whatever). |
[in] | params | Key-value pairs to encode in query string. |
M_FALSE
if there was an encoding error. M_hash_dict_t * M_http_parse_query_string | ( | const char * | data, |
M_textcodec_codec_t | codec | ||
) |
Parse a query string.
Components are expected to be application/x-www-form-urlencoded and will be decoded.
[in] | data | The formatted query arguments. |
[in] | codec | Additional encodings before the data was form encoded. The form decoded data will be decoded to utf-8 from this encoding. Use M_TEXTCODEC_UNKNOWN to skip additional decoding. |
char * M_http_generate_form_data_string | ( | const M_hash_dict_t * | params | ) |
Create form data string.
Data is defined as application/x-www-form-urlencoded data so url form encoding is used.
[in] | params | Key-value pairs to encode in form data string. |
M_bool M_http_generate_form_data_string_buf | ( | M_buf_t * | buf, |
const M_hash_dict_t * | params | ||
) |
Create form data string.
[out] | buf | Buffer to add URI + query string to, contents remain unchanged if there was an error. |
[in] | params | Key-value pairs to encode in query string. |
M_FALSE
if there was an encoding error. M_hash_dict_t * M_http_parse_form_data_string | ( | const char * | data, |
M_textcodec_codec_t | codec | ||
) |
Parse a application/x-www-form-urlencoded paramter string.
Components are expected to be application/x-www-form-urlencoded and will be decoded. This is similar to decoding a query string but this is intended for form data from the body of a message.
[in] | data | The formatted query arguments. |
[in] | codec | Additional encodings before the data was form encoded. The form decoded data will be decoded to utf-8 from this encoding. Use M_TEXTCODEC_UNKNOWN to skip additional decoding. |