-
Notifications
You must be signed in to change notification settings - Fork 45
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
Issue #325 - fixes and testing for HttpServletRequest getServerName #327
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
import static com.google.apphosting.runtime.AppEngineConstants.X_FORWARDED_PROTO; | ||
import static com.google.apphosting.runtime.AppEngineConstants.X_GOOGLE_INTERNAL_PROFILER; | ||
import static com.google.apphosting.runtime.AppEngineConstants.X_GOOGLE_INTERNAL_SKIPADMINCHECK; | ||
import static com.google.apphosting.runtime.jetty9.RpcConnection.NORMALIZE_INET_ADDR; | ||
lachlan-roberts marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import com.google.apphosting.base.protos.HttpPb; | ||
import com.google.apphosting.base.protos.RuntimePb; | ||
|
@@ -67,12 +68,12 @@ | |
import java.util.stream.Stream; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletRequestWrapper; | ||
|
||
import org.eclipse.jetty.http.HttpField; | ||
import org.eclipse.jetty.http.HttpFields; | ||
import org.eclipse.jetty.http.HttpScheme; | ||
import org.eclipse.jetty.http.HttpURI; | ||
import org.eclipse.jetty.server.Request; | ||
import org.eclipse.jetty.util.HostPort; | ||
lachlan-roberts marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Implementation for the {@link RequestAPIData} to allow for the Jetty {@link Request} to be used | ||
|
@@ -128,7 +129,8 @@ public JettyRequestAPIData( | |
|
||
HttpFields fields = new HttpFields(); | ||
for (HttpField field : request.getHttpFields()) { | ||
// If it has a HttpHeader it is one of the standard headers so won't match any appengine specific header. | ||
// If it has a HttpHeader it is one of the standard headers so won't match any appengine | ||
// specific header. | ||
if (field.getHeader() != null) { | ||
fields.add(field); | ||
continue; | ||
|
@@ -286,7 +288,7 @@ public JettyRequestAPIData( | |
traceContext = TraceContextProto.getDefaultInstance(); | ||
} | ||
|
||
String finalUserIp = userIp; | ||
String finalUserIp = NORMALIZE_INET_ADDR ? HostPort.normalizeHost(userIp) : userIp; | ||
lachlan-roberts marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] Just went and checked the source of this change and came across this CL: https://critique.corp.google.com/cl/400610752. Curious if this flag is ever used by the customers? There is a typo in the naming of the property in that it is is called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure which customers could be using this. But this should maintain the behavior of this flag for the We don't currently have this flag available for the Jetty 12 runtimes. It behaves as if But would maybe @gregw or @ludoch have more context on this issue and if customers are require |
||
this.httpServletRequest = | ||
new HttpServletRequestWrapper(httpServletRequest) { | ||
|
||
|
@@ -335,11 +337,6 @@ public String getRemoteAddr() { | |
return finalUserIp; | ||
} | ||
|
||
@Override | ||
public String getServerName() { | ||
return UNSPECIFIED_IP; | ||
} | ||
|
||
@Override | ||
public String getRemoteHost() { | ||
return finalUserIp; | ||
|
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.
Is b3de558#diff-28a36762cb84139431767aee493287f06752c86ae601c79580d77dece0d4d821L350 safe as well? I just realised that the method name is
LocalHostName
and that is the description of the parent method but we are returning the Local IP instead.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.
Not sure exactly what you are referring to here.
But we are not doing any reverse DNS lookups so we never resolve IPs to a hostname.
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.
Sorry I should have clarified the link better:
appengine-java-standard/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyRequestAPIData.java
Line 354 in 3ad247f
If you see we are returning
0.0.0.0
when actually this is supposed to return the host name rather than ip as per https://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getLocalName()