通过proxy_pass 对外发送http请求...
05:37:17.351938 IP 113.108.31.29.80 > 172.16.45.129.51829: Flags [FP.], seq 1:206, ack 1728, win 64240, length 205
0x0000: 4500 00f5 3e3e 0000 8006 91aa 716c 1f1d E...>>......ql..
0x0010: ac10 2d81 0050 ca75 0860 59ff 56b7 ce6f ..-..P.u.`Y.V..o
0x0020: 5019 faf0 2267 0000 4854 5450 2f31 2e31 P..."g..HTTP/1.1
0x0030: 2032 3030 204f 4b0d 0a53 6572 7665 723a .200.OK..Server:
0x0040: 206e 6769 6e78 2f30 2e38 2e35 310d 0a44 .nginx/
0.8.51..D
0x0050: 6174 653a 2054 6875 2c20 3235 204f 6374 ate:.Thu,.25.Oct
0x0060: 2032 3031 3220 3133 3a33 393a 3436 2047 .2012.13:39:46.G
0x0070: 4d54 0d0a 436f 6e74 656e 742d 5479 7065 MT..Content-Type
0x0080: 3a20 7465 7874 2f68 746d 6c0d 0a43 6f6e :.text/html..Con
0x0090: 6e65 6374 696f 6e3a 2063 6c6f 7365 0d0a nection:.close..
0x00a0: 7465 7374 3a20 3530 3120 4e6f 7420 496d test:.
501.Not.Im
0x00b0: 706c 656d 656e 7465 640d 0a43 6f6e 7465 plemented..Conte
0x00c0: 6e74 2d6c 656e 6774 683a 2031 310d 0a43 nt-length:.11..C
0x00d0: 6163 6865 2d43 6f6e 7472 6f6c 3a20 6e6f ache-Control:.no
0x00e0: 2d63 6163 6865 0d0a 0d0a 6261 6420 7265 -cache....
bad.re
0x00f0: 7175 6573 74 quest
lua code:
local res = ngx.location.capture("/abc");
if res.status ~= 200 then
ngx.log(ngx.ERR, res.status, res.body);
ngx.say(json_encode({ret = 502, msg = "share fail"})); return;
else
local r = json_decode(res.body); <<------------执行到这里出现异常,错误日志见下面
if r.ret ~= 0 then
ngx.log(ngx.ERR, res.body);
ngx.say(json_encode({ret = 502, msg = "share fail"})); return;
end
end
2012/10/21 05:37:17 [error] 6951#0: *223948 lua handler aborted: runtime error: /lua/share.lua:41: Expected value but found invalid token at character 1
stack traceback:
[C]: in function 'json_decode'
THX