ahmetb / go-httpbin

http://httpbin.org endpoints for your Go tests

Home Page:https://godoc.org/github.com/ahmetalpbalkan/go-httpbin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Travis CI

gaul opened this issue · comments

Please enable Travis CI to prevent regressions like the current one in 2af00d7:

--- FAIL: TestDeleteCookies (0.00s)
        Error Trace:    handlers_test.go:404
        Error:          "[k3=v3]" does not contain "k1="

FAIL
exit status 1
FAIL    github.com/ahmetalpbalkan/go-httpbin    2.607s

This test succeeds with go 1.7.5 and fails with 1.8. The test is actually wrong; it sets three cookies, deletes two, then checks to see if all three remain.

We don't just check if all 3 exists. We check that 2 are unset (to empty value), 1 is modified but all 3 are present. Since it worked this way with go1.7 just fine, I've reason to believe that either the CookieJar implementation or the http.Client's way of dealing with cookies has changed.

For a cookie defined like this:
http.Cookie{ Name: "k1", Value: "", Path: "/", Expires: time.Unix(0, 0), MaxAge: 0, }

Go 1.7 produce the following string:
k1=; Path=/

While Go 1.9 produce the following string:
k1=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT

This is due to the following fix golang/go@d86a6ef

So now in 1.9 you have a real deletion of the cookie thanks to the expiration time that is correctly set.