Skip to content

net/http: Client doesn't correctly set cookies for all requests - patch attached #3511

@gopherbot

Description

@gopherbot

by steven.hartland@multiplay.co.uk:

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Using a working CookieJar (not the default blackHoleJar)
2. Do a request using the client api to a URL that sets a cookie
3. Do a POST request using the client API for which the above cookie is valid

What is the expected output?
The cookie returned from request in #1 should be set for #2


What do you see instead?
No cookies are set and no call to client.Jar.Cookies(url.URL) for the POST request

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
FreeBSD

Which version are you using?  (run 'go version')
go version go1

Please provide any additional information below.
The attached file is a patch from go1, which fixes this behaviour by delegating the
maintenance of cookies to the now client method send which under pins all actions.

This ensures that every call correctly sends cookies for the request url as well as
saving them on response.

This patch was tested using a work in progress implementation of CookieJar which we'll
also look to submit once complete and tested.

Attachments:

  1. client.go.patch (2101 bytes)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions