Sending headers to GET, HEAD handling fixed

This commit is contained in:
Norbi Peti 2018-01-06 00:24:49 +01:00
parent 0f7b7e7096
commit c33aee426a
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
2 changed files with 2 additions and 1 deletions

View file

@ -32,7 +32,7 @@ public class IOHelper {
public static void SendResponse(int code, String content, HttpExchange exchange) throws IOException {
if (exchange.getRequestMethod().equalsIgnoreCase("HEAD")) {
exchange.sendResponseHeaders(code, 0);
exchange.sendResponseHeaders(code, -1); // -1 indicates no data
exchange.getResponseBody().close();
return;
}

View file

@ -47,6 +47,7 @@ public class BridgePage extends Page {
s = getSocket(exchange);
if (s == null)
return new Response(400, "No connection", exchange);
exchange.sendResponseHeaders(200, 0); // Chunked transfer, any amount of data
IOUtils.copy(s.getInputStream(), exchange.getResponseBody());
exchange.getResponseBody().close(); // TODO: Keep open?
return null; // Response already sen