Skip to content

Deleting cookies no longer works #3445

@jeroen

Description

@jeroen

After fixing #3351 my unit tests were passing, but now they broke again.

What it does

Basically the unit test lets the server set a cookie, then deletes it, and then lists cookies:

  1. create a handle
  2. make a request to https://eu.httpbin.org/cookies/set?foo=123&bar=ftw which sets cookies foo and bar
  3. make a request to https://eu.httpbin.org/cookies/delete?foo which deletes cookie foo.
  4. list cookies with curl_easy_getinfo(handle, CURLINFO_COOKIELIST, &cookies))

Previous output

Up till version 7.62, CURLINFO_COOKIELIST would contain both cookies, with the expired cookie in the list with the timestamp at which it expired, and value as NULL like this:

          domain  flag path secure          expiration name value
1 eu.httpbin.org FALSE    /  FALSE 2019-01-07 23:26:58  foo  <NA>
2 eu.httpbin.org FALSE    /   TRUE                <NA>  bar   ftw

Current output with HTTPS (definitely a bug)

The expired cookie is not deleted at all:

          domain  flag path secure expiration name value
1 eu.httpbin.org FALSE    /   TRUE       <NA>  foo   123
2 eu.httpbin.org FALSE    /   TRUE       <NA>  bar   ftw

New output output with HTTP (maybe a bug?)

The expired cookie is entirely omitted from CURLINFO_COOKIELIST :

          domain  flag path secure expiration name value
1 eu.httpbin.org FALSE    /  FALSE       <NA>  bar   ftw

Full log from R

Sorry for the R code :-)

 library(curl)
 h <- new_handle(verbose = TRUE)
 req <- curl_fetch_memory('https://eu.httpbin.org/cookies/set?foo=123&bar=ftw', handle = h)
*   Trying 34.248.41.77...
* TCP_NODELAY set
* Connected to eu.httpbin.org (34.248.41.77) port 443 (#0)
* ALPN, offering http/1.1
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: eu.httpbin.org
* Server certificate: Let's Encrypt Authority X3
* Server certificate: DST Root CA X3
> GET /cookies/set?foo=123&bar=ftw HTTP/1.1
Host: eu.httpbin.org
User-Agent: R (3.5.2 x86_64-apple-darwin15.6.0 x86_64 darwin15.6.0)
Accept: */*
Accept-Encoding: gzip, deflate

< HTTP/1.1 302 FOUND
< Connection: keep-alive
< Server: gunicorn/19.9.0
< Date: Mon, 07 Jan 2019 22:38:11 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 223
< Location: /cookies
* Added cookie foo="123" for domain eu.httpbin.org, path /, expire 0
< Set-Cookie: foo=123; Secure; Path=/
* Added cookie bar="ftw" for domain eu.httpbin.org, path /, expire 0
< Set-Cookie: bar=ftw; Secure; Path=/
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Via: 1.1 vegur
<
* Ignoring the response-body
* Connection #0 to host eu.httpbin.org left intact
* Issue another request to this URL: 'https://eu.httpbin.org/cookies'
* Found bundle for host eu.httpbin.org: 0x7fc449506050 [can pipeline]
* Re-using existing connection! (#0) with host eu.httpbin.org
* Connected to eu.httpbin.org (34.248.41.77) port 443 (#0)
> GET /cookies HTTP/1.1
Host: eu.httpbin.org
User-Agent: R (3.5.2 x86_64-apple-darwin15.6.0 x86_64 darwin15.6.0)
Accept: */*
Accept-Encoding: gzip, deflate
Cookie: bar=ftw; foo=123

< HTTP/1.1 200 OK
< Connection: keep-alive
< Server: gunicorn/19.9.0
< Date: Mon, 07 Jan 2019 22:38:11 GMT
< Content-Type: application/json
< Content-Length: 59
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Via: 1.1 vegur
<
* Connection #0 to host eu.httpbin.org left intact
req <- curl_fetch_memory('https://eu.httpbin.org/cookies/delete?foo', handle = h)
* Found bundle for host eu.httpbin.org: 0x7fc449506050 [can pipeline]
* Re-using existing connection! (#0) with host eu.httpbin.org
* Connected to eu.httpbin.org (34.248.41.77) port 443 (#0)
> GET /cookies/delete?foo HTTP/1.1
Host: eu.httpbin.org
User-Agent: R (3.5.2 x86_64-apple-darwin15.6.0 x86_64 darwin15.6.0)
Accept: */*
Accept-Encoding: gzip, deflate
Cookie: bar=ftw; foo=123

< HTTP/1.1 302 FOUND
< Connection: keep-alive
< Server: gunicorn/19.9.0
< Date: Mon, 07 Jan 2019 22:38:11 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 223
< Location: /cookies
< Set-Cookie: foo=; Expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Via: 1.1 vegur
<
* Ignoring the response-body
* Connection #0 to host eu.httpbin.org left intact
* Issue another request to this URL: 'https://eu.httpbin.org/cookies'
* Found bundle for host eu.httpbin.org: 0x7fc449506050 [can pipeline]
* Re-using existing connection! (#0) with host eu.httpbin.org
* Connected to eu.httpbin.org (34.248.41.77) port 443 (#0)
> GET /cookies HTTP/1.1
Host: eu.httpbin.org
User-Agent: R (3.5.2 x86_64-apple-darwin15.6.0 x86_64 darwin15.6.0)
Accept: */*
Accept-Encoding: gzip, deflate
Cookie: bar=ftw; foo=123

< HTTP/1.1 200 OK
< Connection: keep-alive
< Server: gunicorn/19.9.0
< Date: Mon, 07 Jan 2019 22:38:11 GMT
< Content-Type: application/json
< Content-Length: 59
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Via: 1.1 vegur
<
* Connection #0 to host eu.httpbin.org left intact
curl::handle_cookies(h)
          domain  flag path secure expiration name value
1 eu.httpbin.org FALSE    /   TRUE       <NA>  foo   123
2 eu.httpbin.org FALSE    /   TRUE       <NA>  bar   ftw

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions