HTTP - general#

Methods#

enum http_method#

HTTP methods.

Values:

enumerator HTTP_INVALID = -1#
enumerator HTTP_DELETE#
enumerator HTTP_GET#
enumerator HTTP_POST#
enumerator HTTP_MIMEPOST#
enumerator HTTP_PATCH#
enumerator HTTP_PUT#
const char *http_method_print(enum http_method method)#

Get the HTTP method name string.

Parameters:
  • method – the HTTP method

Returns:

the HTTP method name

enum http_method http_method_eval(char method[])#

Get the HTTP method enumerator from a string.

Parameters:
  • method – the HTTP method string

Returns:

the HTTP method enumerator

Status Code#

group HttpStatusCode

Defines

HTTP_OK 200#
HTTP_CREATED 201#
HTTP_NO_CONTENT 204#
HTTP_NOT_MODIFIED 304#
HTTP_BAD_REQUEST 400#
HTTP_UNAUTHORIZED 401#
HTTP_FORBIDDEN 403#
HTTP_NOT_FOUND 404#
HTTP_METHOD_NOT_ALLOWED 405#
HTTP_UNPROCESSABLE_ENTITY 422#
HTTP_TOO_MANY_REQUESTS 429#
HTTP_GATEWAY_UNAVAILABLE 502#
const char *http_code_print(int httpcode)#

Get the HTTP status code name string.

Parameters:
  • httpcode – the HTTP status code

Returns:

the HTTP status code name

const char *http_reason_print(int httpcode)#

Get the HTTP status code reason string.

Parameters:
  • httpcode – the HTTP status code

Returns:

the HTTP status code reason

Example#

struct user_agent *ua = ua_init(NULL);
ua_set_url(ua, "https://www.example.com");

struct ua_info info = { 0 };
struct ua_conn_attr conn_attr = { .method = HTTP_GET };

printf("Send %s\n", http_method_print(conn_attr.method));

ua_easy_run(ua, &info, NULL, &conn_attr);

printf("HTTP Status name: %s\n", http_code_print(info.httpcode));
printf("HTTP Status reason %s\n", http_reason_print(info.httpcode));

ua_cleanup(ua);