HTTP Parser and message builder / objects in plain C Snapshot
Classes | Typedefs | Enumerations | Functions
HTTP_REQUEST

http request object. More...

Classes

struct  tagHTTP_REQUEST

Typedefs

typedef int(* HEADER_ACTION )(struct tagHTTP_MESSAGE *request, struct tagHTTP_PARSER *parser)
 callback that is invoked in order to parse contents of a specific http header
typedef enum tagHttp_method_type Http_method_type
typedef enum tagHttp_version_type Http_version_type
typedef struct tagHTTP_REQUEST HTTP_REQUEST

Enumerations

enum  tagHttp_method_type {
  HTTP_METHOD_GET, HTTP_METHOD_POST, HTTP_METHOD_PUT, HTTP_METHOD_HEAD,
  HTTP_METHOD_OPTIONS, HTTP_METHOD_DELETE, HTTP_METHOD_TRACE, HTTP_METHOD_CONNECT
}
enum  tagHttp_version_type { HTTP_VERSION_1_0, HTTP_VERSION_1_1 }

Functions

int HTTP_REQUEST_is_persistent (HTTP_REQUEST *message)
M_INLINE int HTTP_REQUEST_init (HTTP_REQUEST *message)
M_INLINE void HTTP_REQUEST_free (HTTP_REQUEST *message)

Detailed Description

http request object.


Typedef Documentation

typedef int(* HEADER_ACTION)(struct tagHTTP_MESSAGE *request, struct tagHTTP_PARSER *parser)

callback that is invoked in order to parse contents of a specific http header

Definition at line 78 of file http.h.

typedef struct tagHTTP_REQUEST HTTP_REQUEST

Enumeration Type Documentation

Enumerator:
HTTP_METHOD_GET 
HTTP_METHOD_POST 
HTTP_METHOD_PUT 
HTTP_METHOD_HEAD 
HTTP_METHOD_OPTIONS 
HTTP_METHOD_DELETE 
HTTP_METHOD_TRACE 
HTTP_METHOD_CONNECT 

Definition at line 82 of file http.h.

Enumerator:
HTTP_VERSION_1_0 
HTTP_VERSION_1_1 

Definition at line 94 of file http.h.


Function Documentation

M_INLINE void HTTP_REQUEST_free ( HTTP_REQUEST message)

Definition at line 137 of file http.h.

{
  URI_free( &message->url );
  
  if (message->host_header) {
    free( message->host_header);
  }
  if (message->raw_url) {
    free( message->raw_url );
  }

  message->expect_100_continue = message->has_host_header = 0;
  message->raw_url = message->host_header = 0;
  message->has_host_header = 0;
  message->host_header_port = -1;

  HTTP_MESSAGE_free( &message->base );
}
M_INLINE int HTTP_REQUEST_init ( HTTP_REQUEST message)

Definition at line 121 of file http.h.

{
  if (HTTP_MESSAGE_init( &message->base )) {
    return -1;
  }

  URI_init( & message->url );

  message->expect_100_continue = message->has_host_header = 0;
  message->raw_url = message->host_header = 0;
  message->has_host_header = 0;
  message->host_header_port = -1;

  return 0;
}
int HTTP_REQUEST_is_persistent ( HTTP_REQUEST message)

Definition at line 761 of file http.c.

{
  if (message->version == HTTP_VERSION_1_1) {
     if (message->base.flags & HTTP_MESSAGE_FLAG_CONNECTION_CLOSE) {
       return 0;
     }
     return 1;
  }

  if (message->base.flags & HTTP_MESSAGE_FLAG_KEEPALIVE) {
    return 0;
  }
  return 0;
}