Expose remote connection port on RequestHeader#14077
Merged
Merged
Conversation
Add remotePort to RemoteConnection and RequestHeader so request code can inspect the raw peer port when the server backend knows it. Populate the value from Netty and Pekko HTTP socket addresses, keep it through Java request conversion, and expose it on the Java request builder. When trusted forwarded headers replace the remote address, clear the raw port because forwarded port headers are not parsed yet. Add focused tests and docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Expose the remote peer port for incoming requests.
This allows applications to log the same
address:porttuple that can appear in lower-level server logs, making it easier to correlate request logs with connection-level diagnostics.remotePorttoRemoteConnection.RequestHeader.remotePortin Scala.Http.RequestHeader.remotePort()in Java.remotePort(...)support toHttp.RequestBuilder.The exposed value is the remote TCP peer port Play sees directly. With a proxy or load balancer, this is usually the proxy's source port, not the original client's port.
This PR does not add support for
X-Forwarded-Portor RFC 7239 forwarded ports. That will be handled in a upcoming PR.