-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp_parser.h
More file actions
56 lines (46 loc) · 1.47 KB
/
http_parser.h
File metadata and controls
56 lines (46 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// File: http_parser.h
// Created May 27, 2014
// Michael Baptist - mbaptist@ucsc.edu
#ifndef __HTTP_PARSER_H__
#define __HTTP_PARSER_H__
//#define NDEBUG NoDebug
/**
* @file http_parser.h
* This file contains the http header and body parsing functions.
*/
/**
* This will count the number of lines in an http message.
*
* @param buffer The buffer that is filled with the http message.
* @param bufferlen The length of the buffer passed in.
*
* @return The numnber of newline characters.
*/
size_t count_newlines(char buffer[], size_t bufferlen);
/**
* Returns a an array with the http header broken into lines for further parsing. Uses malloc so the array must free each element.
*
* @param buf The http header.
* @param numlines The number of lines in the header.
* @param lines An array to fill with lines;
*
*/
void parse_http_header(char *lines[], char *buf, size_t numlines);
/**
* Parses one line from an http header. Mallocs a slot in an array for each token. Must be freed after use.
*
* @param pieces Array of char pointers that will get filled in with tokens.
* @param line The line to tokenize.
* @param pieceslen The length of the pieces array.
*
*/
void parse_http_header_line(char *pieces[], char *line, size_t pieceslen);
/**
* Frees memory allocations from parsing functions.
*
* @param allocations An array filled with memory from the heap.
* @param len The length of the array.
*
*/
void free_parse_allocs(char *allocations[], int len);
#endif