Documentation ¶
Overview ¶
Package spacecookies implements support for HTTP cookies with a space in their name. Go does not support it https://github.com/golang/go/issues/11519.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport implements a RoundTripper adding space cookies support to an existing RoundTripper.
func New ¶
func New(transport http.RoundTripper, jar http.CookieJar) *Transport
New wraps around a Transport and a Cookie Jar to support cookies with space in the name. Just like an http.Client if transport is nil, http.DefaultTransport is used.
Example ¶
jar, err := cookiejar.New(nil) if err != nil { log.Fatal(err) } client := http.DefaultClient client.Jar = jar // Wrap around the client's transport to add support for space cookies. client.Transport = New(client.Transport, jar) // Assuming example.com sets space cookies, they get added to the jar. resp, err := client.Get("https://example.com") if err != nil { log.Fatal(err) } defer resp.Body.Close() // So that following requests carry these cookies. resp, err = client.Get("https://example.com") if err != nil { log.Fatal(err) } defer resp.Body.Close()
Output:
Click to show internal directories.
Click to hide internal directories.