Software /
code /
prosody
Comparison
net/http/server.lua @ 9624:cc9dff0212f4 0.11
net.http.server: Move event formation to avoid traceback on missing Host header
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 13 Nov 2018 15:03:24 +0000 |
parent | 9562:acf74ad0b795 |
child | 10323:73938168681c |
child | 10950:a23328c46389 |
comparison
equal
deleted
inserted
replaced
9622:269c6df1f0fb | 9624:cc9dff0212f4 |
---|---|
234 err_code, err = 404, "Unknown host: "..host; | 234 err_code, err = 404, "Unknown host: "..host; |
235 else | 235 else |
236 err_code, err = 400, "Missing or invalid 'Host' header"; | 236 err_code, err = 400, "Missing or invalid 'Host' header"; |
237 end | 237 end |
238 end | 238 end |
239 local host_event = request.method.." "..host..request.path:match("[^?]*"); | |
240 | 239 |
241 if err then | 240 if err then |
242 response.status_code = err_code; | 241 response.status_code = err_code; |
243 response:send(events.fire_event("http-error", { code = err_code, message = err, response = response })); | 242 response:send(events.fire_event("http-error", { code = err_code, message = err, response = response })); |
244 return; | 243 return; |
245 end | 244 end |
246 | 245 |
246 local host_event = request.method.." "..host..request.path:match("[^?]*"); | |
247 log("debug", "Firing event: %s", host_event); | 247 log("debug", "Firing event: %s", host_event); |
248 result = events.fire_event(host_event, payload); | 248 result = events.fire_event(host_event, payload); |
249 end | 249 end |
250 if result ~= nil then | 250 if result ~= nil then |
251 if result ~= true then | 251 if result ~= true then |