-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttplite_request.h
More file actions
55 lines (44 loc) · 2.6 KB
/
httplite_request.h
File metadata and controls
55 lines (44 loc) · 2.6 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
#ifndef HTTPLITE_HTTP_REQUEST_H
#define HTTPLITE_HTTP_REQUEST_H
#include <nginx.h>
#include <ngx_core.h>
#include <ngx_event.h>
#include "httplite_upstream.h"
#include "httplite_request_list.h"
enum HTTP_method { GET, POST };
/* Forward declaration */
struct httplite_upstream_s;
/* Data about the connection that is maintained between calls to the request handler*/
typedef struct httplite_client_data_s {
httplite_request_list_t *read_list; /* Where the raw request strings are received into */
httplite_request_list_t *write_list; /* Head of the list where each node is a separate request */
/* The following are utility fields used by request splitting */
httplite_request_list_t *write_list_tail; /* Tail node of the chain of parsed requests */
httplite_request_list_t *staging_list; /* Intermediate holding area for fragmented headers */
size_t bytes_remaining; /* For the current request, how many bytes are left to be copied */
size_t step_number; /* Keeps track of which step in the request parsing we are on */
size_t pending_read_slabs; /* If this gets too large, shuts down the connection */
/* Response handling */
struct httplite_upstream_s *response_upstream; /* Upstream currently sending response to this client */
} httplite_client_data_t;
/* ------------------------------------------------------------------------------
Connection and upstream functions
---------------------------------------------------------------------------- */
void httplite_request_handler(ngx_event_t *rev);
void httplite_close_connection(ngx_connection_t *c);
void httplite_send_request_list(httplite_client_data_t *request_data);
/* ------------------------------------------------------------------------------
Request splitting function
---------------------------------------------------------------------------- */
/**
* given a request_data, parses request_data->read_list into separate requests
* populates them as nodes in write_list
* there will always be one empty node at the end of write list
*/
void httplite_split_request(httplite_client_data_t *request_data, ngx_connection_t *c);
/* ------------------------------------------------------------------------------
Testing functions
---------------------------------------------------------------------------- */
void httplite_print_requests (httplite_request_list_t *requests);
void httplite_print_request (httplite_request_list_t *request);
#endif