#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include "libhttp.h"
Defines | |
#define | MAX_SIZE 4096 |
#define | MAX_BODY_LEN (10 * 1024 * 1024) |
Functions | |
int | http_read (http_t *http, int fd) |
Reads an HTTP request from the file descriptor fd and parses it filling the http_t structure with: request status; request headers; request body (if any). | |
const char * | http_get_header (http_t *http, char *key) |
Returns the value of a HTTP header with the given key. | |
const char * | http_get_status (http_t *http) |
Returns the status of a HTTP request, i.e. | |
const char * | http_get_body (http_t *http, size_t *length) |
Returns the body of a HTTP request. | |
void | http_free (http_t *http) |
Deallocates the resources used for a HTTP request. |
void http_free | ( | http_t * | http | ) |
Deallocates the resources used for a HTTP request.
http | a pointer to an http_t structure to deallocate. |
const char* http_get_body | ( | http_t * | http, | |
size_t * | length | |||
) |
Returns the body of a HTTP request.
http | a pointer to an http_t structure to retrieve the body from. | |
length | if specified, *length gets filled with the total length in bytes of the HTTP body |
const char* http_get_header | ( | http_t * | http, | |
char * | key | |||
) |
Returns the value of a HTTP header with the given key.
http | a pointer to an http_t structure to retrieve the headers from. | |
key | the searched key. |
const char* http_get_status | ( | http_t * | http | ) |
Returns the status of a HTTP request, i.e.
the fist line which terminates with "\r\n".
http | a pointer to an http_t structure to retrieve the status from. |
int http_read | ( | http_t * | http, | |
int | fd | |||
) |
Reads an HTTP request from the file descriptor fd and parses it filling the http_t structure with: request status; request headers; request body (if any).
http | an pointer to an http_t structure to be filled with the data of the HTTP request. | |
fd | a file descriptor where the HTTP stream is read from. |