Skip to content

net/http: Client doesn't correctly set cookies for all requests #3985

Closed
@gopherbot

Description

@gopherbot

by alexandru@mosoi.ro:

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.

1. This bug is a duplicate of bug 3511 which was not correctly fixed
https://golang.org/issue/3511

If req.Method == 'POST' (anything other than GET and HEAD) the bug can be still
reproduced.


2. Here is how to patch test to reproduce the failure.

diff -r 1e84edee3397 src/pkg/net/http/client_test.go
--- a/src/pkg/net/http/client_test.go   Tue Aug 21 20:59:02 2012 +1000
+++ b/src/pkg/net/http/client_test.go   Tue Aug 21 22:45:37 2012 +0200
@@ -284,6 +284,10 @@
    req, _ := NewRequest("GET", us, nil)
    client.Do(req) // Note: doesn't hit network
    matchReturnedCookies(t, expectedCookies, tr.req.Cookies())
+
+   req, _ = NewRequest("POST", us, nil)
+   client.Do(req) // Note: doesn't hit network
+   matchReturnedCookies(t, expectedCookies, tr.req.Cookies())
 }
 
 // Just enough correctness for our redirect tests. Uses the URL.Host as the


3. Currently if req.Method == 'POST', send() is invoked which doesn't set the cookies.
The fix to bug 3511 did not set the cookies on all possible code paths.



What is the expected output?

HTTP cookies set for all methods.

What do you see instead?

HTTP cookies are not set for POST, PUT, etc.

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

6g

Which operating system are you using?

Ubuntu 12.04 LTS (with custom go installation).

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

go version weekly.2012-03-27 +1e84edee3397

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions