Software /
code /
prosody
Comparison
net/http.lua @ 2130:828e161cdfc7
net.httpserver, net.http: Update for new net.server API (untested)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 22 Nov 2009 04:44:26 +0000 |
parent | 1522:569d58d21612 |
child | 2363:a1e987f499a8 |
comparison
equal
deleted
inserted
replaced
2129:fcdcdf00787c | 2130:828e161cdfc7 |
---|---|
150 end | 150 end |
151 if ex.method then req.method = ex.method; end | 151 if ex.method then req.method = ex.method; end |
152 end | 152 end |
153 | 153 |
154 req.handler, req.conn = server.wrapclient(socket.tcp(), req.host, req.port or 80, listener, "*a"); | 154 req.handler, req.conn = server.wrapclient(socket.tcp(), req.host, req.port or 80, listener, "*a"); |
155 req.write = req.handler.write; | 155 req.write = function (...) return req.handler:write(...); end |
156 req.conn:settimeout(0); | 156 req.conn:settimeout(0); |
157 local ok, err = req.conn:connect(req.host, req.port or 80); | 157 local ok, err = req.conn:connect(req.host, req.port or 80); |
158 if not ok and err ~= "timeout" then | 158 if not ok and err ~= "timeout" then |
159 callback(nil, 0, req); | 159 callback(nil, 0, req); |
160 return nil, err; | 160 return nil, err; |
198 end | 198 end |
199 | 199 |
200 function destroy_request(request) | 200 function destroy_request(request) |
201 if request.conn then | 201 if request.conn then |
202 request.handler.close() | 202 request.handler.close() |
203 listener.disconnect(request.conn, "closed"); | 203 listener.ondisconnect(request.conn, "closed"); |
204 end | 204 end |
205 end | 205 end |
206 | 206 |
207 _M.urlencode = urlencode; | 207 _M.urlencode = urlencode; |
208 | 208 |