iodine 0.4.7 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of iodine might be problematic. Click here for more details.

@@ -1,68 +0,0 @@
1
- /*
2
- copyright: Boaz segev, 2016-2017
3
- license: MIT
4
-
5
- Feel free to copy, use and enjoy according to the license provided.
6
- */
7
- #ifndef HTTP1_SIMPLE_PARSER_H
8
- #define HTTP1_SIMPLE_PARSER_H
9
- #include "http1.h"
10
- #include "http_request.h"
11
- #include <stdio.h>
12
-
13
- #ifndef HTTP_HEADERS_LOWERCASE
14
- /** when defined, HTTP headers will be converted to lowercase and header
15
- * searches will be case sensitive. This improves the parser performance in some
16
- * instances (which surprised me.) */
17
- #define HTTP_HEADERS_LOWERCASE 1
18
- #endif
19
-
20
- #ifndef HTTP_PARSER_TEST
21
- /* a debugging flag that adds the test function and decleration */
22
- #define HTTP_PARSER_TEST 0
23
- #endif
24
-
25
- /**
26
- Parses HTTP request headers. This allows review of the expected content length
27
- before accepting any content (server resource management).
28
-
29
- Returns the number of bytes consumed before the full request was accepted.
30
-
31
- Returns -1 on fatal error (i.e. protocol error).
32
- Returns -2 when the request parsing didn't complete.
33
-
34
- Incomplete request parsing updates the content in the buffer. The same buffer
35
- and the same `http_request_s` should be returned to the parsed on the next
36
- attempt, only the `len` argument is expected to grow.
37
-
38
- The buffer should be kept intact for the life of the request object, as the
39
- HTTP/1.1 parser does NOT copy any data.
40
-
41
- The `on_header_found` allows the caller to save any header locations and data.
42
- */
43
- ssize_t http1_parse_request_headers(
44
- void *buffer, size_t len, http_request_s *request,
45
- void (*on_header_found)(http_request_s *request, http_header_s *header));
46
-
47
- /**
48
- Parses HTTP request body content (if any).
49
-
50
- Returns the number of bytes consumed before the body consumption was complete.
51
-
52
- Returns -1 on fatal error (i.e. protocol error).
53
- Returns -2 when the request parsing didn't complete (all the data was consumed).
54
-
55
- Incomplete body parsing doesn't require the buffer to remain static (it can be
56
- recycled).
57
-
58
- It is expected that the next attempt will contain fresh data in the `buffer`
59
- argument.
60
- */
61
- ssize_t http1_parse_request_body(void *buffer, size_t len,
62
- http_request_s *request);
63
-
64
- #if defined(DEBUG) && DEBUG == 1
65
- void http1_parser_test(void);
66
- #endif
67
-
68
- #endif