nginx/src/http/ngx_http.h

264 lines
6.3 KiB
C
Raw Normal View History

#ifndef _NGX_HTTP_H_INCLUDED_
#define _NGX_HTTP_H_INCLUDED_
#include <ngx_config.h>
2002-12-28 00:22:50 +08:00
#include <ngx_types.h>
#include <ngx_string.h>
#include <ngx_table.h>
2002-08-30 00:59:54 +08:00
#include <ngx_hunk.h>
2002-09-02 22:48:24 +08:00
#include <ngx_files.h>
#include <ngx_connection.h>
2002-12-28 00:22:50 +08:00
#include <ngx_conf_file.h>
2003-01-24 02:47:54 +08:00
/* STUB */
#include <ngx_event_timer.h>
2003-03-04 14:33:48 +08:00
#define NGX_HTTP_VERSION_9 9
2002-12-11 02:05:12 +08:00
#define NGX_HTTP_VERSION_10 1000
2003-03-04 14:33:48 +08:00
#define NGX_HTTP_VERSION_11 1001
2002-12-11 02:05:12 +08:00
#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
2002-08-30 00:59:54 +08:00
2002-09-13 22:47:42 +08:00
#define NGX_HTTP_PARSE_HEADER_DONE 1
#define NGX_HTTP_PARSE_INVALID_METHOD 10
#define NGX_HTTP_PARSE_INVALID_REQUEST 11
#define NGX_HTTP_PARSE_TOO_LONG_URI 12
#define NGX_HTTP_PARSE_INVALID_HEAD 13
#define NGX_HTTP_PARSE_INVALID_HEADER 14
2003-03-04 14:33:48 +08:00
#define NGX_HTTP_PARSE_TOO_LONG_HEADER 15
#define NGX_HTTP_PARSE_NO_HOST_HEADER 16
2002-08-30 00:59:54 +08:00
2002-08-16 23:27:03 +08:00
#define NGX_HTTP_OK 200
2003-03-21 00:09:44 +08:00
2002-09-02 22:48:24 +08:00
#define NGX_HTTP_SPECIAL_RESPONSE 300
2002-12-15 14:25:09 +08:00
#define NGX_HTTP_MOVED_PERMANENTLY 301
#define NGX_HTTP_MOVED_TEMPORARILY 302
#define NGX_HTTP_NOT_MODIFIED 304
2003-03-21 00:09:44 +08:00
2002-08-30 00:59:54 +08:00
#define NGX_HTTP_BAD_REQUEST 400
2003-01-10 14:09:20 +08:00
#define NGX_HTTP_FORBIDDEN 403
2002-08-16 23:27:03 +08:00
#define NGX_HTTP_NOT_FOUND 404
2003-03-21 00:09:44 +08:00
#define NGX_HTTP_REQUEST_TIME_OUT 408
2002-09-13 22:47:42 +08:00
#define NGX_HTTP_REQUEST_URI_TOO_LARGE 414
2003-03-21 00:09:44 +08:00
2002-12-15 14:25:09 +08:00
#define NGX_HTTP_INTERNAL_SERVER_ERROR 500
2003-03-12 04:38:13 +08:00
#define NGX_HTTP_NOT_IMPLEMENTED 501
#define NGX_HTTP_BAD_GATEWAY 502
#define NGX_HTTP_SERVICE_UNAVAILABLE 503
#define NGX_HTTP_GATEWAY_TIME_OUT 504
2002-08-16 23:27:03 +08:00
#define NGX_HTTP_STATIC_HANDLER 0
#define NGX_HTTP_DIRECTORY_HANDLER 1
typedef struct {
2003-03-21 00:09:44 +08:00
ngx_str_t name;
int offset;
} ngx_http_header_t;
2002-12-15 14:25:09 +08:00
typedef struct {
2003-02-07 01:21:13 +08:00
size_t host_name_len;
2003-01-28 23:56:37 +08:00
ngx_table_elt_t *host;
ngx_table_elt_t *connection;
2002-12-15 14:25:09 +08:00
ngx_table_elt_t *if_modified_since;
ngx_table_elt_t *accept_encoding;
2003-03-21 00:09:44 +08:00
ngx_table_elt_t *user_agent;
ngx_table_t *headers;
} ngx_http_headers_in_t;
2002-12-15 14:25:09 +08:00
typedef struct {
2002-12-11 02:05:12 +08:00
int status;
ngx_str_t status_line;
ngx_table_elt_t *server;
ngx_table_elt_t *date;
ngx_table_elt_t *content_type;
ngx_table_elt_t *location;
ngx_table_elt_t *last_modified;
ngx_table_t *headers;
off_t content_length;
char *charset;
char *etag;
time_t date_time;
time_t last_modified_time;
2002-08-20 22:48:28 +08:00
} ngx_http_headers_out_t;
2002-12-15 14:25:09 +08:00
typedef struct ngx_http_request_s ngx_http_request_t;
struct ngx_http_request_s {
2003-03-21 00:09:44 +08:00
ngx_connection_t *connection;
2002-12-11 02:05:12 +08:00
2003-03-21 00:09:44 +08:00
void **ctx;
void **srv_conf;
void **loc_conf;
2002-09-07 18:14:25 +08:00
2003-03-21 00:09:44 +08:00
ngx_file_t file;
ngx_pool_t *pool;
ngx_hunk_t *header_in;
2002-08-30 00:59:54 +08:00
ngx_http_headers_in_t headers_in;
ngx_http_headers_out_t headers_out;
2002-08-16 23:27:03 +08:00
int (*handler)(ngx_http_request_t *r);
2002-09-12 22:42:29 +08:00
time_t lingering_time;
2003-03-21 00:09:44 +08:00
int method;
int http_version;
int http_major;
int http_minor;
2003-03-21 00:09:44 +08:00
ngx_str_t request_line;
ngx_str_t uri;
ngx_str_t args;
ngx_str_t exten;
ngx_http_request_t *main;
2003-01-30 01:02:48 +08:00
u_int in_addr;
2003-01-29 15:25:51 +08:00
2003-01-30 01:02:48 +08:00
int port;
ngx_str_t port_name;
2002-08-22 23:24:03 +08:00
2003-01-30 01:02:48 +08:00
int filter;
ssize_t client_content_length;
char *discarded_buffer;
2002-09-02 22:48:24 +08:00
2003-01-10 14:09:20 +08:00
ngx_str_t path;
2003-01-15 15:02:27 +08:00
int path_err;
2003-01-10 14:09:20 +08:00
2003-04-08 23:40:10 +08:00
unsigned proxy:1;
2003-03-05 14:37:42 +08:00
unsigned pipeline:1;
2002-09-12 22:42:29 +08:00
unsigned keepalive:1;
unsigned lingering_close:1;
2002-09-16 23:01:44 +08:00
unsigned header_read:1;
2003-01-27 05:08:14 +08:00
unsigned header_timeout_set:1;
2002-09-13 22:47:42 +08:00
unsigned logging:1;
2002-08-30 00:59:54 +08:00
2002-08-20 22:48:28 +08:00
unsigned header_only:1;
2002-10-05 01:58:04 +08:00
unsigned unusual_uri:1; /* URI is not started with '/' - "GET http://" */
2002-12-15 14:25:09 +08:00
unsigned complex_uri:1; /* URI with "/." or with "//" (WIN32) */
2003-01-10 14:09:20 +08:00
unsigned path_not_found:1;
2003-02-11 15:14:40 +08:00
#ifdef NGX_EVENT
unsigned write_level_event:1;
#endif
int state;
char *uri_start;
char *uri_end;
char *uri_ext;
char *args_start;
2003-03-05 14:37:42 +08:00
char *request_start;
2002-10-05 01:58:04 +08:00
char *request_end;
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
};
2002-12-15 14:25:09 +08:00
2002-08-26 23:18:19 +08:00
typedef struct {
char *action;
char *client;
char *url;
} ngx_http_log_ctx_t;
2003-01-10 14:09:20 +08:00
typedef int (*ngx_http_handler_pt)(ngx_http_request_t *r);
2002-12-26 15:24:21 +08:00
typedef int (*ngx_http_output_header_filter_p)(ngx_http_request_t *r);
typedef int (*ngx_http_output_body_filter_p)
(ngx_http_request_t *r, ngx_chain_t *chain);
#define ngx_http_get_module_ctx(r, module) r->ctx[module.index]
2002-09-07 18:14:25 +08:00
2003-03-12 04:38:13 +08:00
#define ngx_http_create_ctx(r, cx, module, size, error) \
2002-09-11 23:18:33 +08:00
do { \
2003-03-12 04:38:13 +08:00
ngx_test_null(cx, ngx_pcalloc(r->pool, size), error); \
2003-01-09 13:36:00 +08:00
r->ctx[module.index] = cx; \
2002-09-11 23:18:33 +08:00
} while (0)
2002-09-07 18:14:25 +08:00
/* STUB */
#define NGX_INDEX "index.html"
2002-09-02 22:48:24 +08:00
/* STUB */
int ngx_http_init(ngx_pool_t *pool, ngx_log_t *log);
2002-12-15 14:25:09 +08:00
/**/
2002-09-02 22:48:24 +08:00
int ngx_http_init_connection(ngx_connection_t *c);
2003-02-07 01:21:13 +08:00
int ngx_read_http_request_line(ngx_http_request_t *r);
int ngx_read_http_header_line(ngx_http_request_t *r, ngx_hunk_t *h);
int ngx_http_handler(ngx_http_request_t *r);
int ngx_http_send_header(ngx_http_request_t *r);
2003-03-21 00:09:44 +08:00
int ngx_http_special_response_handler(ngx_http_request_t *r, int error);
2003-02-07 01:21:13 +08:00
time_t ngx_http_parse_time(char *value, size_t len);
size_t ngx_http_get_time(char *buf, time_t t);
2002-12-15 14:25:09 +08:00
int ngx_http_discard_body(ngx_http_request_t *r);
2003-01-31 02:21:39 +08:00
2003-01-09 13:36:00 +08:00
extern int ngx_max_module;
extern ngx_array_t ngx_http_servers;
extern int ngx_http_post_accept_timeout;
extern int ngx_http_connection_pool_size;
extern int ngx_http_request_pool_size;
extern int ngx_http_client_header_timeout;
extern int ngx_http_client_header_buffer_size;
2003-03-04 14:33:48 +08:00
extern int ngx_http_large_client_header;
2003-01-09 13:36:00 +08:00
extern int ngx_http_discarded_buffer_size;
2003-03-04 14:33:48 +08:00
extern int ngx_http_url_in_error_log;
2002-09-11 23:18:33 +08:00
2003-03-21 00:09:44 +08:00
extern ngx_array_t ngx_http_translate_handlers;
2003-01-10 14:09:20 +08:00
extern ngx_array_t ngx_http_index_handlers;
2003-04-08 23:40:10 +08:00
extern int (*ngx_http_top_header_filter) (ngx_http_request_t *r);
extern int (*ngx_http_top_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch);
2003-01-10 14:09:20 +08:00
2003-02-07 01:21:13 +08:00
/* STUB */
int ngx_http_log_handler(ngx_http_request_t *r);
/**/
2002-09-11 23:18:33 +08:00
#endif /* _NGX_HTTP_H_INCLUDED_ */