src/http_parser.c File Reference
HTTP protocol parser.
More...
Detailed Description
HTTP protocol parser.
Parses a stream of bytes into a "transaction".
- Date:
- 23 Feb 2010
- Author:
- Zachary Sims <zacs7@users.sourceforge.net>
Module prefix: hp_
$Id$
Function Documentation
bool hp_add_data |
( |
hp_transaction_s * |
transaction, |
|
|
const char * |
data, |
|
|
const size_t |
dataLen | |
|
) |
| | |
Call when you want to add data to a transaction.
- See also:
- hp_parse_data()
- Parameters:
-
| transaction | The transaction to add data to. |
| data | The data to add. |
| dataLen | The length of the data to add. |
- Returns:
true
on success. On error, false
is returned.
Initialise a blank HTTP transaction.
It must be freed with http_free_transaction().
- See also:
- http_free_transaction()
- Parameters:
-
| role | The role the parser will take. |
- Returns:
- A blank HTTP transaction. On error, NULL is returned.
Return the host if given.
The hostname will not exceed HTTP_LIMIT_HOSTNAME_LENGTH.
- Returns:
- The host to connect to (nul terminated) as a IP or hostname.
already "cached"
Returns the parsed host port (default of HTTP_DEFAULT_PORT if none given).
- Parameters:
-
| transaction | The transaction to return from. |
- Returns:
- The port of the host given in the request path or Host: header.
Gets the method of the request.
- Parameters:
-
| transaction | The transaction to return from. |
- Returns:
- the request method.
Returns how much raw data there is.
- Parameters:
-
| transaction | The transaction to check if there is unread data on. |
- Returns:
- The number of raw bytes that haven't been read yet. 0 if there are none.
size_t hp_get_raw_bytes |
( |
hp_transaction_s * |
transaction, |
|
|
char * |
buffer, |
|
|
const size_t |
bufferLen | |
|
) |
| | |
Gets the raw bytes from the transaction.
- Parameters:
-
| transaction | The raw bytes to return. |
| buffer | The buffer to write to. |
| bufferLen | The maximum size of buffer. |
- Returns:
- >0 if buffer contains raw bytes. On EOF or error 0 is returned.
Parse the message buffered.
- See also:
- hp_add_data()
- Parameters:
-
| transaction | The transaction to parse. |
- Returns:
true
on success. On error, false
is returned.
- Todo:
- HTTP_ROLE_CLIENT for parsing response line
- Todo:
- use the return value of path and header fields.
bool hp_set_header_field_value |
( |
const hp_transaction_s * |
transaction, |
|
|
const char * |
value | |
|
) |
| | |
Sets a header field value.
Returns true if the value was set. On error, false is returned.
- Parameters:
-
| transaction | The transaction to set the header field value of. |
| value | |
- Todo:
- Replace field value OR add it to the end of the headers.
- Todo:
- Detect EOL style from transaction
Free a HTTP transaction.
- Parameters:
-
| transaction | The transaction to free. |