|
HTTP Parser and message builder / objects in plain C Snapshot
|
Holds common data of both HTTP request and response objects. More...
Classes | |
| struct | tagSTRINGPAIR |
| struct | tagHTTP_MESSAGE |
Typedefs | |
| typedef struct tagSTRINGPAIR | STRINGPAIR |
| typedef struct tagHTTP_MESSAGE | HTTP_MESSAGE |
Functions | |
| int | HTTP_MESSAGE_init (HTTP_MESSAGE *message) |
| void | HTTP_MESSAGE_free (HTTP_MESSAGE *message) |
| int | HTTP_MESSAGE_add_header (HTTP_MESSAGE *message, const char *name, const char *value) |
| M_INLINE void | HTTP_MESSAGE_set_content_length (HTTP_MESSAGE *message, int content_length) |
| const char * | HTTP_MESSAGE_find_header (HTTP_MESSAGE *message, const char *name) |
| STRINGPAIR * | HTTP_MESSAGE_first_header (HTTP_MESSAGE *message, DLISTUNR_position *pos) |
| STRINGPAIR * | HTTP_MESSAGE_next_header (HTTP_MESSAGE *message, DLISTUNR_position *pos) |
Holds common data of both HTTP request and response objects.
| typedef struct tagHTTP_MESSAGE HTTP_MESSAGE |
| typedef struct tagSTRINGPAIR STRINGPAIR |
| int HTTP_MESSAGE_add_header | ( | HTTP_MESSAGE * | message, |
| const char * | name, | ||
| const char * | value | ||
| ) |
Definition at line 105 of file http.c.
{
STRINGPAIR entry;
entry.key = strdup(name);
entry.value = strdup(value);
return DLISTUNR_push_back( &message->header_values, &entry, sizeof(entry));
}
| const char* HTTP_MESSAGE_find_header | ( | HTTP_MESSAGE * | message, |
| const char * | name | ||
| ) |
Definition at line 115 of file http.c.
{
DLISTUNR_position idx;
STRINGPAIR *cur;
DLISTUNR_FOREACH( idx, &message->header_values ) {
cur = (STRINGPAIR *) DLISTUNR_at( &message->header_values, idx );
if (strcmp(cur->key, name) == 0) {
return cur->value;
}
}
return 0;
}
| STRINGPAIR* HTTP_MESSAGE_first_header | ( | HTTP_MESSAGE * | message, |
| DLISTUNR_position * | pos | ||
| ) |
Definition at line 128 of file http.c.
{
*pos = DLISTUNR_get_first( &message->header_values );
return (STRINGPAIR *) DLISTUNR_at( &message->header_values, *pos );
}
| void HTTP_MESSAGE_free | ( | HTTP_MESSAGE * | message | ) |
Definition at line 97 of file http.c.
{
message->flags = 0;
message->content_length = -1;
DLISTUNR_free( &message->header_values, free_stringpair, 0);
}
| int HTTP_MESSAGE_init | ( | HTTP_MESSAGE * | message | ) |
Definition at line 86 of file http.c.
{
message->flags = 0;
message->content_length = -1;
if (DLISTUNR_init( &message->header_values, sizeof(STRINGPAIR), 10) ) {
return -1;
}
return 0;
}
| STRINGPAIR* HTTP_MESSAGE_next_header | ( | HTTP_MESSAGE * | message, |
| DLISTUNR_position * | pos | ||
| ) |
Definition at line 134 of file http.c.
{
if (pos->entry == (DLISTUNR_entry *) &message->header_values.root) {
return 0;
}
*pos = DLISTUNR_next( *pos );
return (STRINGPAIR *) DLISTUNR_at( &message->header_values, *pos );
}
| M_INLINE void HTTP_MESSAGE_set_content_length | ( | HTTP_MESSAGE * | message, |
| int | content_length | ||
| ) |
Definition at line 44 of file http.h.
{
message->flags |= HTTP_MESSAGE_FLAG_HAS_CONTENT_LENGTH;
message->content_length = content_length;
}
1.7.4