Skip to content
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

net/http: Responses should have a field for connection information #7842

Closed
gopherbot opened this issue Apr 23, 2014 · 7 comments
Closed

net/http: Responses should have a field for connection information #7842

gopherbot opened this issue Apr 23, 2014 · 7 comments

Comments

@gopherbot
Copy link

by ask@develooper.com:

Similar to the new TLS field with the tls.ConnectionState in the http.Response struct
it'd be useful to get access to some connection information.

For my use case I was missing the IP the client connected to (RemoteAddr); I am not sure
if there's other information in the current connection API that would be useful to
expose.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-none.

@josharian
Copy link
Contributor

Comment 2:

Same for Requests, please.
We run http servers with a custom network stack, and we just hit a situation in which
we'd like to be able to inspect the underlying net.Conn from an http.Handler, in order
to get at security information associated with the connection.
I'm happy to implement. Brad, before I start, any concerns or API commentary? The
obvious thing to do is to expose the net.Conn directly in each case and document it as
read-only and not to be stored, but that enables all kinds of foot-shooting.

Status changed to Accepted.

@josharian
Copy link
Contributor

Comment 3:

See also discussion at https://groups.google.com/forum/#!topic/Golang-nuts/cMs8b7iL5KI.

@bradfitz
Copy link
Contributor

Comment 4:

I'd prefer to stop growing Request and Response, both for memory and API bloat reasons.
Is it possible to achieve this via a new optional hook on *http.Transport instead? Some
callback that happens at certain point(s) with the Request or Response and gives you the
net.Conn info and then you can do what you will with the info, perhaps stuffing it in
magic headers on your request or reply even...?)

@josharian
Copy link
Contributor

Comment 5:

We found a workaround.  Can't speak for the OP.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@ysmolski
Copy link
Member

ysmolski commented Nov 6, 2018

Not sure if I should close the issue. It has some important bits, but @josharian found a solution back in time which involved something other than modifying the net/http. There was in interest to this issues in last 4 years. My bet that we can close it down.

@bradfitz
Copy link
Contributor

bradfitz commented Nov 6, 2018

Closing as duplicate of #5465 and #23707 (which I sketched out recently but haven't yet mailed).

@bradfitz bradfitz closed this as completed Nov 6, 2018
@golang golang locked and limited conversation to collaborators Nov 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants