Skip to content

proposal: net/http: add support for proxy basic authentication #55290

@shalev67

Description

@shalev67

The current implementation of the http.Reuest allows parsing and setting the basic authentication username and password using the BasicAuth and SetBasicAuth methods. When authenticating to a http proxy server the http client and server are using a different header for the basic authentication - "Proxy-Authorization" described in RFC 2068, Section 14. Supporting parsing and setting proxy basic authentication is currently not covered in the net/http package and would be very helpful when programming http proxy client/server.

To help tackle this, I propose the following API:

// ProxyBasicAuth returns the username and password provided in the request's
// Proxy-Authorization header, if the request uses HTTP Basic Authentication.
// See RFC 2068, Section 14.
(r *Request) ProxyBasicAuth() (username, password string, ok bool)

// SetProxyBasicAuth sets the request's Proxy-Authorization header to use HTTP
// Basic Authentication with the provided username and password.
(r *Request) SetProxyBasicAuth(username, password string)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions