src/http/ngx_http.h - nginx-1.31.3 nginx/ @ 42f8df65b

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              *line_start;
  59.     u_char              *start;
  60.     u_char              *end;
  61. } ngx_http_status_t;


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


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


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

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


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


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

  113. void ngx_http_empty_handler(ngx_event_t *wev);
  114. void ngx_http_request_empty_handler(ngx_http_request_t *r);


  115. #define NGX_HTTP_LAST   1
  116. #define NGX_HTTP_FLUSH  2

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


  118. ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
  119.     ngx_http_client_body_handler_pt post_handler);
  120. ngx_int_t ngx_http_read_unbuffered_request_body(ngx_http_request_t *r);

  121. ngx_int_t ngx_http_send_header(ngx_http_request_t *r);
  122. ngx_int_t ngx_http_send_early_hints(ngx_http_request_t *r);
  123. ngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r,
  124.     ngx_int_t error);
  125. ngx_int_t ngx_http_filter_finalize_request(ngx_http_request_t *r,
  126.     ngx_module_t *m, ngx_int_t error);
  127. void ngx_http_clean_header(ngx_http_request_t *r);


  128. ngx_int_t ngx_http_discard_request_body(ngx_http_request_t *r);
  129. void ngx_http_discarded_request_body_handler(ngx_http_request_t *r);
  130. void ngx_http_block_reading(ngx_http_request_t *r);
  131. void ngx_http_test_reading(ngx_http_request_t *r);


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

  138. #if (NGX_HTTP_DEGRADATION)
  139. ngx_uint_t  ngx_http_degraded(ngx_http_request_t *);
  140. #endif


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


  147. extern ngx_module_t  ngx_http_module;

  148. extern ngx_str_t  ngx_http_html_default_types[];


  149. extern ngx_http_output_header_filter_pt  ngx_http_top_header_filter;
  150. extern ngx_http_output_header_filter_pt  ngx_http_top_early_hints_filter;
  151. extern ngx_http_output_body_filter_pt    ngx_http_top_body_filter;
  152. extern ngx_http_request_body_filter_pt   ngx_http_top_request_body_filter;


  153. #endif /* _NGX_HTTP_H_INCLUDED_ */