Software /
code /
prosody
Comparison
net/http/server.lua @ 11409:d30c44a829c1
net.http.server: Set request.ip so mod_http doesn't have to
Because it already sets request.secure, which depends on the connection,
just like the IP, so it makes sense to do both in the same place.
Dealing with proxies can be left to mod_http for now, but maybe it could
move into some util some day?
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 27 Feb 2021 21:37:16 +0100 |
parent | 11373:ad3b5384fc03 |
child | 11527:eaff6e548f12 |
comparison
equal
deleted
inserted
replaced
11408:1b6298e7b550 | 11409:d30c44a829c1 |
---|---|
111 | 111 |
112 local function noop() end | 112 local function noop() end |
113 function listener.onconnect(conn) | 113 function listener.onconnect(conn) |
114 local session = { conn = conn }; | 114 local session = { conn = conn }; |
115 local secure = conn:ssl() and true or nil; | 115 local secure = conn:ssl() and true or nil; |
116 local ip = conn:ip(); | |
116 session.thread = async.runner(function (request) | 117 session.thread = async.runner(function (request) |
117 local wait, done; | 118 local wait, done; |
118 if request.partial == true then | 119 if request.partial == true then |
119 -- Have the header for a request, we want to receive the rest | 120 -- Have the header for a request, we want to receive the rest |
120 -- when we've decided where the data should go. | 121 -- when we've decided where the data should go. |
125 end | 126 end |
126 handle_request(conn, request, done); wait(); | 127 handle_request(conn, request, done); wait(); |
127 end, runner_callbacks, session); | 128 end, runner_callbacks, session); |
128 local function success_cb(request) | 129 local function success_cb(request) |
129 --log("debug", "success_cb: %s", request.path); | 130 --log("debug", "success_cb: %s", request.path); |
131 request.ip = ip; | |
130 request.secure = secure; | 132 request.secure = secure; |
131 session.thread:run(request); | 133 session.thread:run(request); |
132 end | 134 end |
133 local function error_cb(err) | 135 local function error_cb(err) |
134 log("debug", "error_cb: %s", err or "<nil>"); | 136 log("debug", "error_cb: %s", err or "<nil>"); |