Nginx 3-ngx_http_request_t struct

Source: Internet
Author: User

Ngx_http_request_s is a very important structure in nginx, which runs through the entire process of htpp request processing.

The following describes the important member variables related to the HTTP framework in the ngx_http_request_s struct.

Struct ngx_http_request_s {uint32_t signature;/* "HTTP" * // request the corresponding client to connect to ngx_connection_t * connection; // void ** CTX, a pointer to the context struct that stores all HTTP modules; // void ** main_conf, a pointer array that stores the main-level Configuration struct corresponding to the request; // point to the void ** srv_conf pointer array for storing the SRV-level Configuration struct corresponding to the request; // point to the void array for storing the Loc-level Configuration struct corresponding to the request ** loc_conf; /** after receiving the HTTP header and processing the HTTP request for the first time, the HTTP framework provides the ngx_http_process_request processing method. However, if this method cannot process all the services of the request at one time, the ngx_http_request_handler method will be used when the request is called back again after the control is returned to the epoll time module, in this method, the read event is processed by calling read_event_handler to process the request. That is to say, the HTTP module wants to re-implement the read_event_handler Method */ngx_http_event_handler_pt read_event_handler when processing the read event of the request at the underlying layer; // similar to the preceding method, export write_event_handler; # If) ngx_http_cache_t * cache; # The structure ngx_http_upstream_t * upstream used by the endif // upstream mechanism; ngx_array_t * upstream_states;/* of bytes * // The requested memory pool ngx_pool_t * pool; // a buffer for receiving HTTP request content. It mainly receives the ngx_buf_t * Header of the HTTP header. _ In; // After receiving and parsing the HTTP Request Header, ngx_http_process_request_headers adds each parsed HTTP header to the headers linked list of headers_in, at the same time, other members of headers_in ngx_http_headers_in_t headers_in will be constructed; // The HTTP module will put the corresponding HTTP information to be sent in headers_out, the HTTP framework is expected to serialize the members in headers_out into an HTTP response packet and send it to the user ngx_http_headers_out_t headers_out; // receives the data structure ngx_http_request_body_t * request_body in the request; // The time when the connection is delayed. time_t lingering_time; // The time when the current request is initialized. time_t start_sec; ngx_msec_t Start_msec; // The nine members below are the information parsed by the ngx_http_process_request_line method when receiving and parsing HTTP requests; // The method name ngx_uint_t http_version; // Protocol version ngx_str_t request_line; ngx_str_t URI; // URI ngx_str_t ARGs in the user request; // The URL parameter ngx_str_t exten in the user request; // the file extension ngx_str_t unparsed_uri requested by the user; // The original request ngx_str_t method_name without URL Decoding; // The method name string ngx_str_t http_protocol in the user request; // The data member points to the HTTP start address in the request/* indicates the HTTP Response to be sent to the client. Out stores the TCP stream that represents the HTTP header after being serialized in headers_out. * After the ngx_http_output_filter method is called, the http package body to be sent is stored in the out, which is the key to asynchronous HTTP Response sending. */Ngx_chain_t * out;/* the current request may be either a user request or a derived subrequest. * Main identifies a series of related original requests for sending child requests. * Generally, you can determine whether the current request is an original request sent by the user by checking whether the main and current request addresses are equal. */Ngx_http_request_t * main; // The parent request of the current request (not necessarily the original request) ngx_http_request_t * parent; // features related to the subrequest ngx_http_postponed_request_t * postponed; * post_subrequest; // All subrequests are ngx_http_posted_request_t * posted_requests linked through this single-chain table;/* the global response struct defines an array consisting of ngx_http_phase_handler_t answer methods. * The phase_handler member is used with the array. Indicates that the next request should execute phase_handler as the callback method in the array specified by the serial number */ngx_int_t phase_handler; // indicates a way that the ngx_http_content_phase stage provides to the HTTP module to process requests, it points to the request processing method ngx_http_handler_pt content_handler implemented by the HTTP module; // when the ngx_http_access_phase node needs to determine whether the request has access permissions, it uses access_code to pass the return value of the handler callback method of the HTTP module, if the value is 0, the account has the permission. Otherwise, it is unavailable. Ngx_uint_t access_code; ngx_http_variable_value_t * variables; # If (ngx_pcre) ngx_uint_t ncaptures; int * captures; u_char * captures_data; # endif size_limit_rate; /* used to learn the Apache compatible response length without a header */size_t header_size; // the full length of the HTTP request, including the http package off_t request_length; ngx_uint_t err_status; optional * http_connection; # If (ngx_http_spdy) ngx_http_spdy_stream_t * spdy_stream; # endif ngx_http_log_handler_pt log_handler; // if some resources are opened in this request and need to be released at the end of the request, you need to add the defined method for releasing resources to this member ngx_http_cleanup_t * cleanup; unsigned subrequests: 8; // The reference count is generally applied to the original request of this request. // reference count, each time a subrequest is derived, the Count member of the original request will add an unsigned count: 8; // blocking flag. Currently, only the unsigned blocked: 8 is used by AIO; // flag: 1 indicates that the egg request is using asynchronous Io unsigned AIO: 1; unsigned http_state: 4;/* URI "/. "And on Win32 with" // "*/unsigned complex_uri: 1;/* URI with" % "*/unsigned quoted_uri: 1; /* URI with "+" */unsigned plus_in_uri: 1;/* URI with "" */unsigned space_in_uri: 1; unsigned invalid_header: 1; unsigned Expiration: 1; unsigned valid_location: 1; unsigned valid_unparsed_uri; unsigned attributes: 1; unsigned attributes: 1; unsigned attributes: 1; unsigned attributes: 1; unsigned attributes: 1; unsigned attributes: 3; unsigned subrequest_in_memory: 1; unsigned waited: 1; # If (ngx_http_cache) unsigned cached: 1; # endif # If (IF) unsigned gzip_tested: 1; unsigned gzip_ OK: 1; unsigned gzip_vary: 1; # endif unsigned Proxy: 1; unsigned bypass_cache: 1; unsigned no_cache: 1;/** instead of using the request Context Data in * ngx_http_limit_conn_module and usage * we use the single bits in the request structure */unsigned limit_conn_set: 1; unsigned limit_req_set: 1; # If 0 unsigned cacheable: 1; # endif unsigned pipeline: 1; unsigned chunked: 1; unsigned header_only: 1; // flag, if it is set to 1, the keepalive request for the current request is unsigned keepalive: 1; // the flag of the unsigned lingering_close: 1; // flag: 1 indicates that the packet body unsigned discard_body: 1 in the HTTP request is being discarded; // The flag bit: 1 indicates that the current status of the request is redirected internally to unsigned internal: 1; unsigned error_page: 1; unsigned ignore_content_encoding: 1; unsigned filter_finalize: 1; unsigned post_action: 1; unsigned request_complete: 1; unsigned request_output: 1; // flag: 1 indicates that the HTTP Response Header sent to the client has sent unsigned header_sent: 1; unsigned expect_tested: 1; unsigned root_tested: 1; unsigned done: 1; unsigned logged: 1; // flag, indicating whether to send unsigned buffered: 4; unsigned cached: 1; unsigned filter_need_in_memory: 1; unsigned filter_need_temporary: 1; unsigned allow_ranges: 1; # If (ngx_stat_stub) unsigned stat_reading: 1; unsigned stat_writing: 1; # endif/* used to parse HTTP headers * // The state machine uses State to indicate the current resolution status when parsing HTTP. You need to check whether the ngx_uint_t state of the completed HTTP request line is formed; using header_hash; ngx_uint_t lowcase_index; u_char lowcase_header [encoding]; u_char * header_name_start; u_char * header_name_end; u_char * header_start; u_char * header_end; /** a memory that can be reused after parsing a request line * via character */u_char * uri_start; u_char * uri_end; u_char * uri_ext; u_char * args_start; u_char * request_start; u_char * character; u_char * method_end; u_char * character; u_char * host_start; u_char * host_end; u_char * port_start; u_char * port_end; unsigned character: 16; unsigned character: 16 ;};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.