src/http.h File Reference

Typedefs

typedef enum http_method_tag http_method_e
typedef enum http_version_tag http_version_e
typedef enum http_content_type_tag http_content_type_e
typedef enum http_connection_tag http_connection_e
typedef enum
http_transfer_encoding_tag 
http_transfer_encoding_e

Enumerations

enum  http_method_tag {
  HTTP_METHOD_UNKNOWN = 0, HTTP_METHOD_GET, HTTP_METHOD_POST, HTTP_METHOD_HEAD,
  HTTP_METHOD_OPTIONS, HTTP_METHOD_TRACE, HTTP_METHOD_PUT, HTTP_METHOD_DELETE
}
enum  http_version_tag {
  HTTP_VERSION_UNKNOWN = 0, HTTP_VERSION_09 = 9, HTTP_VERSION_10 = 10, HTTP_VERSION_11 = 11,
  HTTP_VERSION_12 = 12
}
enum  http_content_type_tag { HTTP_CONTENT_TYPE_HTML = 0, HTTP_CONTENT_TYPE_PLAIN }
enum  http_connection_tag { HTTP_CONNECTION_KEEPALIVE = 0, HTTP_CONNECTION_CLOSE }
enum  http_transfer_encoding_tag { HTTP_TRANSFER_CHUNKED = 0, HTTP_TRANSFER_NORMAL }

Functions

const char * http_get_code_description (const int code)
 Returns the description of a HTTP code.
http_version_e http_lookup_version (const char *version)
 Looks up a HTTP version from a HTTP version string.
const char * http_return_version (const http_version_e version)
 Returns a valid HTTP version string from the enumeration.
http_method_e http_lookup_method (const char *method, const size_t n)
 Looks up a method enumeration from a method string.
char * http_create_response (const http_version_e version, const int code, const http_connection_e connection, const http_content_type_e type, const char *message)
 Create a response string based on the given code and HTTP version.
void http_free_response (char *response)
 Free a response string returned from http_create_response().
const char * http_get_content_type_string (const http_content_type_e type)
 Returns the string value of a HTTP content type.

Typedef Documentation


Enumeration Type Documentation

Enumerator:
HTTP_CONNECTION_KEEPALIVE 
HTTP_CONNECTION_CLOSE 
Enumerator:
HTTP_CONTENT_TYPE_HTML 
HTTP_CONTENT_TYPE_PLAIN 
Enumerator:
HTTP_METHOD_UNKNOWN 
HTTP_METHOD_GET 
HTTP_METHOD_POST 
HTTP_METHOD_HEAD 
HTTP_METHOD_OPTIONS 
HTTP_METHOD_TRACE 
HTTP_METHOD_PUT 
HTTP_METHOD_DELETE 
Enumerator:
HTTP_TRANSFER_CHUNKED 
HTTP_TRANSFER_NORMAL 
Enumerator:
HTTP_VERSION_UNKNOWN 
HTTP_VERSION_09 
HTTP_VERSION_10 
HTTP_VERSION_11 
HTTP_VERSION_12 

Function Documentation

char* http_create_response ( const http_version_e  version,
const int  code,
const http_connection_e  connection,
const http_content_type_e  type,
const char *  message 
)

Create a response string based on the given code and HTTP version.

Returns:
a string that should be freed with http_response_free(). On error, NULL is returned.

Todo:
Use connection value

void http_free_response ( char *  response  ) 

Free a response string returned from http_create_response().

See also:
http_create_response()
Parameters:
response The response to free.
const char* http_get_code_description ( const int  code  ) 

Returns the description of a HTTP code.

All errors are kept in an internal static constant array.

Parameters:
code The HTTP code.
Returns:
The code description. On error, NULL is returned if the code cannot be found.
const char* http_get_content_type_string ( const http_content_type_e  type  ) 

Returns the string value of a HTTP content type.

Parameters:
type The type to lookup.
Returns:
a string value of the type.
http_method_e http_lookup_method ( const char *  method,
const size_t  n 
)

Looks up a method enumeration from a method string.

Even though the HTTP spec says case sensitive, ignore that ;).

Parameters:
method The method.
n The length of the method.
Todo:
the n parameter isn't really required.
Returns:
a http_method_tag return value.
http_version_e http_lookup_version ( const char *  version  ) 

Looks up a HTTP version from a HTTP version string.

Even though the HTTP spec says case sensitive, ignore that ;).

Parameters:
version The version string. Assumed to contain a valid version.
Returns:
a http_version_tag return value. On error, HTTP_VERSION_UNKNOWN is returned.
const char* http_return_version ( const http_version_e  version  ) 

Returns a valid HTTP version string from the enumeration.

Parameters:
version The enumerated HTTP version.
Returns:
a HTTP version string. On error, NULL is returned.

Generated by  doxygen 1.6.2