src/http.c File Reference

HTTP utility functions. More...

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_decode_uri (const char *uri)
char * http_encode_uri (const char *uri)
char * http_html_escape (const char *html)
void http_free (const char *item)
const char * http_get_content_type_string (const http_content_type_e type)
 Returns the string value of a HTTP content type.
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().

Detailed Description

HTTP utility functions.

Date:
23 Feb 2010
Author:
Zachary Sims <zacs7@users.sourceforge.net>

Module prefix: http_

$Id$

Todo:
More consistant naming for returning/looking up enum values.

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

char* http_decode_uri ( const char *  uri  ) 
See also:
http_free()
char* http_encode_uri ( const char *  uri  ) 
See also:
http_free()
void http_free ( const char *  item  ) 
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.
char* http_html_escape ( const char *  html  ) 
See also:
http_free()
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