Comparison

net/http.lua @ 8046:1bf47706aefb

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Sun, 02 Apr 2017 00:24:37 +0200
parent 7798:74cfec1fe5a2
parent 8045:55a56dc935f2
child 8121:a33a87f13155
comparison
equal deleted inserted replaced
8044:e38e3300b955 8046:1bf47706aefb
66 end 66 end
67 67
68 function listener.ondisconnect(conn, err) 68 function listener.ondisconnect(conn, err)
69 local request = requests[conn]; 69 local request = requests[conn];
70 if request and request.conn then 70 if request and request.conn then
71 request:reader(nil, err); 71 request:reader(nil, err or "closed");
72 end 72 end
73 requests[conn] = nil; 73 requests[conn] = nil;
74 end 74 end
75 75
76 function listener.ondetach(conn) 76 function listener.ondetach(conn)
124 124
125 local function request(u, ex, callback) 125 local function request(u, ex, callback)
126 local req = url.parse(u); 126 local req = url.parse(u);
127 127
128 if not (req and req.host) then 128 if not (req and req.host) then
129 callback(nil, 0, req); 129 callback("invalid-url", 0, req);
130 return nil, "invalid-url"; 130 return nil, "invalid-url";
131 end 131 end
132 132
133 if not req.path then 133 if not req.path then
134 req.path = "/"; 134 req.path = "/";
188 sslctx = ex and ex.sslctx or { mode = "client", protocol = "sslv23", options = { "no_sslv2", "no_sslv3" } }; 188 sslctx = ex and ex.sslctx or { mode = "client", protocol = "sslv23", options = { "no_sslv2", "no_sslv3" } };
189 end 189 end
190 190
191 local handler, conn = server.addclient(host, port_number, listener, "*a", sslctx) 191 local handler, conn = server.addclient(host, port_number, listener, "*a", sslctx)
192 if not handler then 192 if not handler then
193 callback(nil, 0, req); 193 callback(conn, 0, req);
194 return nil, conn; 194 return nil, conn;
195 end 195 end
196 req.handler, req.conn = handler, conn 196 req.handler, req.conn = handler, conn
197 req.write = function (...) return req.handler:write(...); end 197 req.write = function (...) return req.handler:write(...); end
198 198