-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullPointerException when http header host is null #418
Conversation
7eed82c
to
6986935
Compare
2b4ac25
to
a8b7424
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a nit
@@ -133,6 +133,8 @@ public Publisher<Void> processRequest(ProxyRequest request) { | |||
return serveInternalErrorMessage(request); | |||
case MAINTENANCE_MODE: | |||
return serverMaintenanceMessage(request); | |||
case BAD_REQUEST: | |||
return serverBadRequestMessage(request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serveBadRequestMessage
return requestHostname.substring(0, colonIndex); | ||
} | ||
} catch (NumberFormatException e) { | ||
return ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe in that case is it better to return badRequest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pv3nturi Fixed
@@ -171,6 +174,27 @@ public String getRequestHostname() { | |||
return request.requestHeaders().get(HttpHeaderNames.HOST); | |||
} | |||
|
|||
public String getHostname() { | |||
String requestHostname = getRequestHostname(); | |||
int colonIndex = requestHostname.indexOf(":"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May this throw NPE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pv3nturi Fixed
48e300f
to
55bdd0b
Compare
f070a08
to
84a17b8
Compare
@pv3nturi PTAL |
84a17b8
to
88d839c
Compare
#412
As per RFC, if host header is missing or wrong the response must be 400 Bad request.
See https://www.rfc-editor.org/rfc/rfc2616#page-38
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host
the error page can be customized by setting:
default.action.badrequest=custom_action