src/http/ngx_http.h - nginx source code

Data types defined

Macros defined

Source code


  1. /*
  2. * Copyright (C) Igor Sysoev
  3. * Copyright (C) Nginx, Inc.
  4. */


  5. #ifndef _NGX_HTTP_H_INCLUDED_
  6. #define _NGX_HTTP_H_INCLUDED_


  7. #include <ngx_config.h>
  8. #include <ngx_core.h>


  9. typedef struct ngx_http_request_s     ngx_http_request_t;
  10. typedef struct ngx_http_upstream_s    ngx_http_upstream_t;
  11. typedef struct ngx_http_cache_s       ngx_http_cache_t;
  12. typedef struct ngx_http_file_cache_s  ngx_http_file_cache_t;
  13. typedef struct ngx_http_log_ctx_s     ngx_http_log_ctx_t;
  14. typedef struct ngx_http_chunked_s     ngx_http_chunked_t;
  15. typedef struct ngx_http_v2_stream_s   ngx_http_v2_stream_t;
  16. typedef struct ngx_http_v3_parse_s    ngx_http_v3_parse_t;
  17. typedef struct ngx_http_v3_session_s  ngx_http_v3_session_t;

  18. typedef ngx_int_t (*ngx_http_header_handler_pt)(ngx_http_request_t *r,
  19.     ngx_table_elt_t *h, ngx_uint_t offset);
  20. typedef u_char *(*ngx_http_log_handler_pt)(ngx_http_request_t *r,
  21.     ngx_http_request_t *sr, u_char *buf, size_t len);


  22. #include <ngx_http_variables.h>
  23. #include <ngx_http_config.h>
  24. #include <ngx_http_request.h>
  25. #include <ngx_http_script.h>
  26. #include <ngx_http_upstream.h>
  27. #include <ngx_http_upstream_round_robin.h>
  28. #include <ngx_http_core_module.h>

  29. #if (NGX_HTTP_V2)
  30. #include <ngx_http_v2.h>
  31. #endif
  32. #if (NGX_HTTP_V3)
  33. #include <ngx_http_v3.h>
  34. #endif
  35. #if (NGX_HTTP_CACHE)
  36. #include <ngx_http_cache.h>
  37. #endif
  38. #if (NGX_HTTP_SSI)
  39. #include <ngx_http_ssi_filter_module.h>
  40. #endif
  41. #if (NGX_HTTP_SSL)
  42. #include <ngx_http_ssl_module.h>
  43. #endif


  44. struct ngx_http_log_ctx_s {
  45.     ngx_connection_t    *connection;
  46.     ngx_http_request_t  *request;
  47.     ngx_http_request_t  *current_request;
  48. };


  49. struct ngx_http_chunked_s {
  50.     ngx_uint_t           state;
  51.     off_t                size;
  52.     off_t                length;
  53. };


  54. typedef struct {
  55.     ngx_uint_t           http_version;
  56.     ngx_uint_t           code;
  57.     ngx_uint_t           count;
  58.     u_char              *start;
  59.     u_char              *end;
  60. } ngx_http_status_t;


  61. #define ngx_http_get_module_ctx(r, module)  (r)->ctx[module.ctx_index]
  62. #define ngx_http_set_ctx(r, c, module)      r->ctx[module.ctx_index] = c;


  63. ngx_int_t ngx_http_add_location(ngx_conf_t *cf, ngx_queue_t **locations,
  64.     ngx_http_core_loc_conf_t *clcf);
  65. ngx_int_t ngx_http_add_listen(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,
  66.     ngx_http_listen_opt_t *lsopt);


  67. void ngx_http_init_connection(ngx_connection_t *c);
  68. void ngx_http_close_connection(ngx_connection_t *c);

  69. #if (NGX_HTTP_SSL && defined SSL_CTRL_SET_TLSEXT_HOSTNAME)
  70. int ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg);
  71. #endif
  72. #if (NGX_HTTP_SSL && defined SSL_R_CERT_CB_ERROR)
  73. int ngx_http_ssl_certificate(ngx_ssl_conn_t *ssl_conn, void *arg);
  74. #endif


  75. ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b);
  76. ngx_int_t ngx_http_parse_uri(ngx_http_request_t *r);
  77. ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r,
  78.     ngx_uint_t merge_slashes);
  79. ngx_int_t ngx_http_parse_status_line(ngx_http_request_t *r, ngx_buf_t *b,
  80.     ngx_http_status_t *status);
  81. ngx_int_t ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri,
  82.     ngx_str_t *args, ngx_uint_t *flags);
  83. ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b,
  84.     ngx_uint_t allow_underscores);
  85. ngx_table_elt_t *ngx_http_parse_multi_header_lines(ngx_http_request_t *r,
  86.     ngx_table_elt_t *headers, ngx_str_t *name, ngx_str_t *value);
  87. ngx_table_elt_t *ngx_http_parse_set_cookie_lines(ngx_http_request_t *r,
  88.     ngx_table_elt_t *headers, ngx_str_t *name, ngx_str_t *value);
  89. ngx_int_t ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len,
  90.     ngx_str_t *value);
  91. void ngx_http_split_args(ngx_http_request_t *r, ngx_str_t *uri,
  92.     ngx_str_t *args);
  93. ngx_int_t ngx_http_parse_chunked(ngx_http_request_t *r, ngx_buf_t *b,
  94.     ngx_http_chunked_t *ctx, ngx_uint_t keep_trailers);


  95. ngx_http_request_t *ngx_http_create_request(ngx_connection_t *c);
  96. ngx_int_t ngx_http_process_request_uri(ngx_http_request_t *r);
  97. ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r);
  98. void ngx_http_process_request(ngx_http_request_t *r);
  99. void ngx_http_update_location_config(ngx_http_request_t *r);
  100. void ngx_http_handler(ngx_http_request_t *r);
  101. void ngx_http_run_posted_requests(ngx_connection_t *c);
  102. ngx_int_t ngx_http_post_request(ngx_http_request_t *r,
  103.     ngx_http_posted_request_t *pr);
  104. ngx_int_t ngx_http_set_virtual_server(ngx_http_request_t *r,
  105.     ngx_str_t *host);
  106. ngx_int_t ngx_http_validate_host(ngx_str_t *host, ngx_pool_t *pool,
  107.     ngx_uint_t alloc);
  108. void ngx_http_close_request(ngx_http_request_t *r, ngx_int_t rc);
  109. void ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc);
  110. void ngx_http_free_request(ngx_http_request_t *r, ngx_int_t rc);

  111. void ngx_http_empty_handler(ngx_event_t *wev);
  112. void ngx_http_request_empty_handler(ngx_http_request_t *r);


  113. #define NGX_HTTP_LAST   1
  114. #define NGX_HTTP_FLUSH  2

  115. ngx_int_t ngx_http_send_special(ngx_http_request_t *r, ngx_uint_t flags);


  116. ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
  117.     ngx_http_client_body_handler_pt post_handler);
  118. ngx_int_t ngx_http_read_unbuffered_request_body(ngx_http_request_t *r);

  119. ngx_int_t ngx_http_send_header(ngx_http_request_t *r);
  120. ngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r,
  121.     ngx_int_t error);
  122. ngx_int_t ngx_http_filter_finalize_request(ngx_http_request_t *r,
  123.     ngx_module_t *m, ngx_int_t error);
  124. void ngx_http_clean_header(ngx_http_request_t *r);


  125. ngx_int_t ngx_http_discard_request_body(ngx_http_request_t *r);
  126. void ngx_http_discarded_request_body_handler(ngx_http_request_t *r);
  127. void ngx_http_block_reading(ngx_http_request_t *r);
  128. void ngx_http_test_reading(ngx_http_request_t *r);


  129. char *ngx_http_types_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
  130. char *ngx_http_merge_types(ngx_conf_t *cf, ngx_array_t **keys,
  131.     ngx_hash_t *types_hash, ngx_array_t **prev_keys,
  132.     ngx_hash_t *prev_types_hash, ngx_str_t *default_types);
  133. ngx_int_t ngx_http_set_default_types(ngx_conf_t *cf, ngx_array_t **types,
  134.     ngx_str_t *default_type);

  135. #if (NGX_HTTP_DEGRADATION)
  136. ngx_uint_t  ngx_http_degraded(ngx_http_request_t *);
  137. #endif


  138. #if (NGX_HTTP_V2 || NGX_HTTP_V3)
  139. ngx_int_t ngx_http_huff_decode(u_char *state, u_char *src, size_t len,
  140.     u_char **dst, ngx_uint_t last, ngx_log_t *log);
  141. size_t ngx_http_huff_encode(u_char *src, size_t len, u_char *dst,
  142.     ngx_uint_t lower);
  143. #endif


  144. extern ngx_module_t  ngx_http_module;

  145. extern ngx_str_t  ngx_http_html_default_types[];


  146. extern ngx_http_output_header_filter_pt  ngx_http_top_header_filter;
  147. extern ngx_http_output_body_filter_pt    ngx_http_top_body_filter;
  148. extern ngx_http_request_body_filter_pt   ngx_http_top_request_body_filter;


  149. #endif /* _NGX_HTTP_H_INCLUDED_ */