nginx HTTP functionality is implemented by the ngx_http_range_filter_module.
In fact, this module is composed of two modules, one of ngx_http_range_header_filter_module,
Http header information provided in response to, for example: set the content-range, specified response interval block start end position;
Provided content-length, body size when the response packet specifies HTTP; 206 is provided in response to the response code instead of 200 yards and the like.
Another module ngx_http_range_body_filter_module, a block for the specified content from the buffer zone, and the contents of the block range to the client.
Most event Nginx method epoll EPOLLET (edge-triggered) to trigger an event, the event read only listen port is EPOLLLT (level trigger).
For edge-triggered, if the event occurs readable, and must in time, otherwise it may appear to read event is no longer triggered connected deaths have been reported.
CPU spin locks
Nginx event handler entry function is ngx_process_events_and_timers ()
ngx_process_events () function is the entry handle all events, it will traverse all events.
Acquisition parameters Variable Description:
--Attributes
method = ngx.var.request_method -- http://wiki.nginx.org/HttpCoreModule#.24request_method
schema = ngx.var.schema - http://wiki.nginx.org/HttpCoreModule#.24scheme
host = ngx.var.host -- http://wiki.nginx.org/HttpCoreModule#.24host
hostname = ngx.var.hostname - http://wiki.nginx.org/HttpCoreModule#.24hostname
poetry = ngx.var.request_uri - http://wiki.nginx.org/HttpCoreModule#.24request_uri
path = ngx.var.uri - http://wiki.nginx.org/HttpCoreModule#.24uri
filename = ngx.var.request_filename -- http://wiki.nginx.org/HttpCoreModule#.24request_filename
query_string = ngx.var.query_string -- http://wiki.nginx.org/HttpCoreModule#.24query_string
user_agent = ngx.var.http_user_agent -- http://wiki.nginx.org/HttpCoreModule#.24http_HEADER
remote_addr = ngx.var.remote_addr -- http://wiki.nginx.org/HttpCoreModule#.24remote_addr
remote_port = ngx.var.remote_port -- http://wiki.nginx.org/HttpCoreModule#.24remote_port
remote_user = ngx.var.remote_user -- http://wiki.nginx.org/HttpCoreModule#.24remote_user
remote_passwd = ngx.var.remote_passwd -- http://wiki.nginx.org/HttpCoreModule#.24remote_passwd
content_type = ngx.var.content_type -- http://wiki.nginx.org/HttpCoreModule#.24content_type
content_length = ngx.var.content_length -- http://wiki.nginx.org/HttpCoreModule#.24content_length
headers = ngx.req.get_headers() -- http://wiki.nginx.org/HttpLuaModule#ngx.req.get_headers
uri_args = ngx.req.get_uri_args() -- http://wiki.nginx.org/HttpLuaModule#ngx.req.get_uri_args
post_args = ngx.req.get_post_args() -- http://wiki.nginx.org/HttpLuaModule#ngx.req.get_post_args
socket = ngx.req.socket -- http://wiki.nginx.org/HttpLuaModule#ngx.req.socket
--method
request:read_body() -- http://wiki.nginx.org/HttpLuaModule#ngx.req.read_body
request:get_uri_arg(name, default)
request:get_post_arg(name, default)
request:get_arg(name, default)
request:get_cookie(key, decrypt)
request:rewrite(uri, jump) -- http://wiki.nginx.org/HttpLuaModule#ngx.req.set_uri
request:set_uri_args(args) -- http://wiki.nginx.org/HttpLuaModule#ngx.req.set_uri_args
Properties and methods 3.4 response object
--Attributes
headers = ngx.header - http://wiki.nginx.org/HttpLuaModule#ngx.header.HEADER
--method
response:set_cookie(key, value, encrypt, duration, path)
response:write(content)
response:writeln(content)
response:ltp(template,data)
response:redirect(url, status) -- http://wiki.nginx.org/HttpLuaModule#ngx.redirect
response:finish() -- http://wiki.nginx.org/HttpLuaModule#ngx.eof
response:is_finished()
response: defer (func, ...) - executed after the response is returned
3.5 print debug log
ngx.escape_uri (str) url escape
ngx.unescape_uri (str) url escaped reduction
ngx.encode_args () encoding the lua table as a query parameter string
ngx.decode_args (str, max_args?) the query string to lua table