Tor
0.4.7.0-alpha-dev
|
Parse a subset of the HTTP protocol. More...
Go to the source code of this file.
Macros | |
#define | PROTO_HTTP_PRIVATE |
#define | CONTENT_LENGTH "\r\nContent-Length: " |
Functions | |
int | peek_buf_has_http_command (const buf_t *buf) |
int | fetch_from_buf_http (buf_t *buf, char **headers_out, size_t max_headerlen, char **body_out, size_t *body_used, size_t max_bodylen, int force_complete) |
STATIC int | buf_http_find_content_length (const char *headers, size_t headerlen, size_t *result_out) |
Parse a subset of the HTTP protocol.
Definition in file proto_http.c.
STATIC int buf_http_find_content_length | ( | const char * | headers, |
size_t | headerlen, | ||
size_t * | result_out | ||
) |
Scan the HTTP headers in the headerlen-byte memory range at headers, looking for a "Content-Length" header. Try to set *result_out to the numeric value of that header if possible. Return -1 if the header was malformed, 0 if it was missing, and 1 if it was present and well-formed.
Definition at line 139 of file proto_http.c.
int fetch_from_buf_http | ( | buf_t * | buf, |
char ** | headers_out, | ||
size_t | max_headerlen, | ||
char ** | body_out, | ||
size_t * | body_used, | ||
size_t | max_bodylen, | ||
int | force_complete | ||
) |
There is a (possibly incomplete) http statement on buf, of the form "\%s\\r\\n\\r\\n\%s", headers, body. (body may contain NULs.) If a) the headers include a Content-Length field and all bytes in the body are present, or b) there's no Content-Length field and all headers are present, then:
Else, change nothing and return 0.
Definition at line 50 of file proto_http.c.
Referenced by connection_fetch_from_buf_http(), and connection_read_https_proxy_response().
int peek_buf_has_http_command | ( | const buf_t * | buf | ) |
Return true if cmd looks like a HTTP (proxy) request.
Definition at line 19 of file proto_http.c.