Chinaunix首页 | 论坛 | 博客
  • 博客访问: 519944
  • 博文数量: 78
  • 博客积分: 995
  • 博客等级: 准尉
  • 技术积分: 1462
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-15 20:22
个人简介

技术中沉思的时候最快乐,问题得到完美解决的时候最有成就感!

文章分类

全部博文(78)

文章存档

2013年(39)

2012年(37)

2011年(2)

分类: Python/Ruby

2012-05-18 19:07:31

简单的使用,比较简单,很快就ok了,可以参考:
http://blog.chinaunix.net/uid-26443921-id-3213846.html


然后是重点戏了:
前一周一直在解决的“lua扩展”,要上战场了;

1,拷贝lua和tolua++的so,拷贝到 /usr/local/lib, ldconfig 下
2,将 thrift.so 等业务相关so 拷贝到 /usr/local/lib 下面;
2,将之前生成的自定义so拷贝到 /usr/local/lib/lua/5.1/ 下面
3,修改 test_lua 


点击(此处)折叠或打开

  1. require "xdrive_datagram_lua"
  2. require "datagram_http_lua"

  3. print("input cookies=", ngx.var.http_cookie)

  4. ngx.say("input params : [", ngx.var.args, "]")

  5. local params = ngx.req.get_uri_args()

  6. if params.uid ~= "5760273" then
  7.         ngx.status = 403
  8.         return
  9. end

  10. local p = comm.protocal
  11. local dt_header = p.xdrive_datagram_header_t()

  12. local seq = tonumber(params.seq)
  13. if seq then
  14.         dt_header._sequence = seq
  15. end

  16. local http_req = p.http_head_req()
  17. local args_http = http_req:base().arguments

  18. for k, v in pairs(params) do
  19.         if type(v) == "boolean" then
  20.                 v = "1"
  21.         end
  22.         std.maprs2s:set_kv(args_http, k, v)
  23. end

  24. local cookies = ngx.var.http_cookie
  25. if cookies then
  26.         std.parase_http_params(cookies, #cookies, http_req:base().cookies)
  27. end

  28. ngx.say(p.xdrive_header_to_string(dt_header))
  29. ngx.say(http_req:to_string())


测试
wget -S "" --header='Host: test_dl' --header='Cookie: nickname=xxxxooooxxxx' -O /tmp/a.txt; cat /tmp/a.txt
--2012-05-18 19:28:45--  
Connecting to 127.0.0.1:80... 已连接。
已发出 HTTP 请求,正在等待回应... 
  HTTP/1.1 200 OK
  Server: nginx/1.0.8
  Date: Fri, 18 May 2012 11:28:45 GMT
  Content-Type: application/octet-stream
  Content-Length: 735
  Connection: keep-alive
长度:735 [application/octet-stream]
Saving to: `/tmp/a.txt'

100%[==========================================================================================>] 735         --.-K/s   in 0s      

2012-05-18 19:28:45 (35.0 MB/s) - `/tmp/a.txt' saved [735/735]

input params : [uid=5760273&gcid=fdsafgdfasgadf&xdrive_id&seq=1002255877]

head: {magic: 0x1c420f80; msg type: 0; version: 1; sequence: 1002255877; status: 0; length: 0}

HttpHeadReq {
  01: method (i32) = 1278554344,
  02: uri (string) = "",
  03: arguments (map) = map[4] {
    "gcid" -> "fdsafgdfasgadf",
    "seq" -> "1002255877",
    "uid" -> "5760273",
    "xdrive_id" -> "1",
  },
  04: cookies (map) = map[1] {
    "nickname" -> "xxxxooooxxxx",
  },
  05: other_heads (map) = map[0] {
  },
  06: bytes_range (struct) = HttpBytesRange {
    01: range_set (byte) = 0x00,
    02: head (i64) = 0,
    03: last (i64) = -1,
    04: total_size (i64) = -1,
  },
  07: last (byte) = 0x00,
}
测试通过,非常开心!!!

阅读(13824) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~