nginx相关的一些特性

内容比较琐碎

后面持续补充吧......

 

nginx断点续传功能是由ngx_http_range_filter_module实现的

其实这个模块是由两个模块组成的,一个为ngx_http_range_header_filter_module,

用于设置http响应的头部信息,例如: 设置content-range,指定应答的区间块开始结束位置;

设置content-length, 指定断点续传时的应答包体大小; 设置206响应码而不是200响应码等等。

 

另一个模块为ngx_http_range_body_filter_module, 用于从缓冲区中查找指定区间块内容,并把这个区间块的内容发给客户端。

 

Nginx大部分event采用epoll EPOLLET(边沿触发)的方法来触发事件,只有listen端口的读事件是EPOLLLT(水平触发)。

对于边沿触发,如果出现了可读事件,必须及时处理,否则可能会出现读事件不再触发,连接饿死的情况。

 

CPU自旋锁

 

Nginx事件处理的入口函数是ngx_process_events_and_timers()

ngx_process_events()函数是所有事件处理的入口,它会遍历所有的事件。

 

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

uri = 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

 

 

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

headers = ngx.header -- http://wiki.nginx.org/HttpLuaModule#ngx.header.HEADER

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, ...) -- 在response返回后执行

 

ngx.escape_uri(str) url转义

ngx.unescape_uri(str) url转义还原

ngx.encode_args() 把lua table编码为查询参数字符串

ngx.decode_args(str,max_args?) 把查询字符串转为lua table

 

Lua GC 的对象

JIT 编译器不支持的原语被称为 NYI(Not Yet Implemented)原语。

永远不会被编译,比如基于经典的 lua_CFunction 方式实现的 Lua C 模块(所以需要尽量通过 LuaJIT 的 FFI 来调用 C)

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值