Software /
code /
prosody
Comparison
net/http/server.lua @ 11373:ad3b5384fc03
net.http.server: Don't pause early streaming uploads
Fixes that otherwise it would wait for the request to be done after
receiving the head of the request, when it's meant to select a target
for where to store the data, instead of waiting after receiving the
request for when the request has been handled.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 13 Feb 2021 13:38:56 +0100 |
parent | 11372:b877bd74d65e |
child | 11409:d30c44a829c1 |
comparison
equal
deleted
inserted
replaced
11372:b877bd74d65e | 11373:ad3b5384fc03 |
---|---|
107 log("error", "Traceback[httpserver]: %s", err); | 107 log("error", "Traceback[httpserver]: %s", err); |
108 self.data.conn:write("HTTP/1.0 500 Internal Server Error\r\n\r\n"..events.fire_event("http-error", { code = 500, private_message = err })); | 108 self.data.conn:write("HTTP/1.0 500 Internal Server Error\r\n\r\n"..events.fire_event("http-error", { code = 500, private_message = err })); |
109 self.data.conn:close(); | 109 self.data.conn:close(); |
110 end | 110 end |
111 | 111 |
112 local function noop() end | |
112 function listener.onconnect(conn) | 113 function listener.onconnect(conn) |
113 local session = { conn = conn }; | 114 local session = { conn = conn }; |
114 local secure = conn:ssl() and true or nil; | 115 local secure = conn:ssl() and true or nil; |
115 session.thread = async.runner(function (request) | 116 session.thread = async.runner(function (request) |
116 local wait, done = async.waiter(); | 117 local wait, done; |
118 if request.partial == true then | |
119 -- Have the header for a request, we want to receive the rest | |
120 -- when we've decided where the data should go. | |
121 wait, done = noop, noop; | |
122 else -- Got the entire request | |
123 -- Hold off on receiving more incoming requests until this one has been handled. | |
124 wait, done = async.waiter(); | |
125 end | |
117 handle_request(conn, request, done); wait(); | 126 handle_request(conn, request, done); wait(); |
118 end, runner_callbacks, session); | 127 end, runner_callbacks, session); |
119 local function success_cb(request) | 128 local function success_cb(request) |
120 --log("debug", "success_cb: %s", request.path); | 129 --log("debug", "success_cb: %s", request.path); |
121 request.secure = secure; | 130 request.secure = secure; |