Software / code / prosody
Comparison
net/httpserver.lua @ 2571:8a16c5e92bcb
net.httpserver: Make request.conn be the server.lua conn instead of the underlying socket (more useful this way)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 08 Feb 2010 11:22:21 +0000 |
| parent | 2570:9e69aecad25e |
| child | 2925:692b3c6c5bd2 |
comparison
equal
deleted
inserted
replaced
| 2570:9e69aecad25e | 2571:8a16c5e92bcb |
|---|---|
| 212 body = "<html><head><title>Page Not Found</title></head><body>Not here :(</body></html>" }; | 212 body = "<html><head><title>Page Not Found</title></head><body>Not here :(</body></html>" }; |
| 213 end | 213 end |
| 214 | 214 |
| 215 | 215 |
| 216 function new_request(handler) | 216 function new_request(handler) |
| 217 return { handler = handler, conn = handler.socket, | 217 return { handler = handler, conn = handler, |
| 218 write = function (...) return handler:write(...); end, state = "request", | 218 write = function (...) return handler:write(...); end, state = "request", |
| 219 server = http_servers[handler:serverport()], | 219 server = http_servers[handler:serverport()], |
| 220 send = send_response, | 220 send = send_response, |
| 221 destroy = destroy_request, | 221 destroy = destroy_request, |
| 222 id = tostring{}:match("%x+$") | 222 id = tostring{}:match("%x+$") |
| 234 else | 234 else |
| 235 log("debug", "Request has no destroy callback"); | 235 log("debug", "Request has no destroy callback"); |
| 236 end | 236 end |
| 237 request.handler:close() | 237 request.handler:close() |
| 238 if request.conn then | 238 if request.conn then |
| 239 listener.ondisconnect(request.handler, "closed"); | 239 listener.ondisconnect(request.conn, "closed"); |
| 240 end | 240 end |
| 241 end | 241 end |
| 242 end | 242 end |
| 243 | 243 |
| 244 function new(params) | 244 function new(params) |