summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http.h
blob: fe89874ddb93536fc3f58cd6496e6e7ef72c30c9 (plain) (blame)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef _NGX_HTTP_H_INCLUDED_
#define _NGX_HTTP_H_INCLUDED_


#include <ngx_config.h>
#include <ngx_types.h>
#include <ngx_hunk.h>
#include <ngx_file.h>
#include <ngx_connection.h>


#define NGX_HTTP_GET   1
#define NGX_HTTP_HEAD  2
#define NGX_HTTP_POST  3

#define NGX_HTTP_CONN_CLOSE       0
#define NGX_HTTP_CONN_KEEP_ALIVE  1


#define NGX_HTTP_HEADER_DONE            1
#define NGX_HTTP_INVALID_METHOD         10
#define NGX_HTTP_INVALID_REQUEST        11
#define NGX_HTTP_INVALID_HEAD           12
#define NGX_HTTP_INVALID_HEADER         13


#define NGX_HTTP_OK                     200
#define NGX_HTTP_MOVED_PERMANENTLY      302
#define NGX_HTTP_BAD_REQUEST            400
#define NGX_HTTP_NOT_FOUND              404
#define NGX_HTTP_INTERNAL_SERVER_ERROR  503


#define NGX_HTTP_STATIC_HANDLER     0
#define NGX_HTTP_DIRECTORY_HANDLER  1


typedef struct {
    void *ctx;   /* STUB */
} ngx_http_module_t;

/* STUB */
#define ngx_get_module_ctx(r, module)  (module)->ctx

typedef struct {
    char          *doc_root;
    size_t         doc_root_len;
    size_t         buff_size;

    unsigned int   header_timeout;
} ngx_http_server_t;

typedef struct {
    char *buff;
    char *pos;
    char *last;
    char *end;
} ngx_buff_t;

typedef struct {
    int     status;
    int     connection;
    off_t   content_length;
    char   *location;
    char   *content_type;
    char   *charset;
    char   *etag;
    char   *server;
    time_t  date;
    time_t  last_modified;
} ngx_http_headers_out_t;

typedef struct ngx_http_request_s ngx_http_request_t;

struct ngx_http_request_s {
    char  *filename;
    char  *location;
    ngx_fd_t  fd;

    ngx_pool_t  *pool;
    ngx_hunk_t  *header_in;

/*
    ngx_http_headers_in_t *headers_in;
*/
    ngx_http_headers_out_t *headers_out;

    int    filename_len;
    int  (*handler)(ngx_http_request_t *r);

    ngx_file_info_t file_info;

    int    method;

    int    http_version;
    int    http_major;
    int    http_minor;

    char  *uri;
    ngx_http_request_t *main;

    ngx_connection_t  *connection;
    ngx_http_server_t *server;

    int       filter;

    unsigned  header_timeout:1;

    unsigned  header_only:1;
    unsigned  unusual_uri:1;
    unsigned  complex_uri:1;

    int    state;
    char  *uri_start;
    char  *uri_end;
    char  *uri_ext;
    char  *args_start;
    char  *header_name_start;
    char  *header_name_end;
    char  *header_start;
    char  *header_end;
#ifdef NGX_EVENT
    int  (*state_handler)(ngx_http_request_t *r);
#endif
};

typedef struct {
    char  *action;
    char  *client;
    char  *url;
} ngx_http_log_ctx_t;


#define NGX_INDEX "index.html"


int ngx_http_init_connection(ngx_connection_t *c);


#endif /* _NGX_HTTP_H_INCLUDED_ */