Silent handling of bridge errors
No longer reporting breaking pipes on bridges #11
This commit is contained in:
parent
a4cf26556f
commit
73b02518a4
1 changed files with 14 additions and 6 deletions
|
@ -53,9 +53,13 @@ public class BridgePage extends Page {
|
||||||
return new Response(400, "No connection", exchange);
|
return new Response(400, "No connection", exchange);
|
||||||
if (s.isClosed())
|
if (s.isClosed())
|
||||||
return new Response(410, "Socket Gone", exchange);
|
return new Response(410, "Socket Gone", exchange);
|
||||||
|
try {
|
||||||
exchange.sendResponseHeaders(200, 0); // Chunked transfer, any amount of data
|
exchange.sendResponseHeaders(200, 0); // Chunked transfer, any amount of data
|
||||||
copyStream(s.getInputStream(), exchange.getResponseBody());
|
copyStream(s.getInputStream(), exchange.getResponseBody());
|
||||||
exchange.getResponseBody().close(); // It'll only get here when the communication is already done
|
exchange.getResponseBody().close(); // It'll only get here when the communication is already done
|
||||||
|
} catch (IOException ex) { //Failed to send it over HTTP, GET connection closed
|
||||||
|
closeSocket(exchange); //We only have one GET, connection over
|
||||||
|
}
|
||||||
return null; // Response already sent
|
return null; // Response already sent
|
||||||
case "DELETE":
|
case "DELETE":
|
||||||
System.out.println("[BWM] [" + id + "] delet this");
|
System.out.println("[BWM] [" + id + "] delet this");
|
||||||
|
@ -65,7 +69,12 @@ public class BridgePage extends Page {
|
||||||
return new Response(403, "Unknown request", exchange);
|
return new Response(403, "Unknown request", exchange);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
if (e instanceof SocketException) {
|
||||||
|
closeSocket(exchange);
|
||||||
|
return new Response(410, "Socket Gone because of error: " + e, exchange);
|
||||||
|
}
|
||||||
|
e.printStackTrace();
|
||||||
|
return new Response(500, "Internal Server Error: " + e, exchange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,8 +101,7 @@ public class BridgePage extends Page {
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
socket.close();
|
socket.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException ignored) {
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
connections.values().remove(socket);
|
connections.values().remove(socket);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue