Fixes #749 - Invalid WebSocket Upgrade should result in error 400, not 405

This commit is contained in:
Joakim Erdfelt 2016-08-01 10:06:22 -07:00
parent 0ecc8caff6
commit 3ea5c29ea6
1 changed files with 6 additions and 4 deletions

View File

@ -81,8 +81,9 @@ public class ServletUpgradeResponse extends UpgradeResponse
public void sendError(int statusCode, String message) throws IOException
{
setSuccess(false);
commitHeaders();
applyHeaders();
response.sendError(statusCode, message);
response.flushBuffer(); // commit response
response = null;
}
@ -90,8 +91,9 @@ public class ServletUpgradeResponse extends UpgradeResponse
public void sendForbidden(String message) throws IOException
{
setSuccess(false);
commitHeaders();
applyHeaders();
response.sendError(HttpServletResponse.SC_FORBIDDEN, message);
response.flushBuffer(); // commit response
response = null;
}
@ -111,11 +113,11 @@ public class ServletUpgradeResponse extends UpgradeResponse
public void complete()
{
commitHeaders();
applyHeaders();
response = null;
}
private void commitHeaders()
private void applyHeaders()
{
// Transfer all headers to the real HTTP response
for (Map.Entry<String, List<String>> entry : getHeaders().entrySet())