Skip to content

net/http: document that ProxyFromEnvironment special-cases localhost #7256

Closed
@gopherbot

Description

@gopherbot

by mislav.marohnic:

Go respects HTTP_PROXY environment variables, **except** when the original request is to
"localhost" or "127.0.0.1".

This special case is surprising (it's not documented) and undesired. I've come across
this when I tried to debug a go program that makes HTTP requests by passing all
communication through a HTTP debugging proxy:

  http_proxy=localhost:8888 myprog ...

However since this program makes HTTP requests to a *local test server*, my proxy
configuration was silently ignored.

The only way around this was to literally reimplement `http.ProxyFromEnvironment` in my
program without the needless special case for localhost.

go version 1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions