Opened 15 years ago

Closed 15 years ago

#24584 closed enhancement (fixed)

port fetch should use a cookie jar

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: macports-tickets@…
Priority: Normal Milestone: MacPorts 1.9.0
Component: base Version: 1.8.2
Keywords: Cc:
Port:

Description

Some servers require a cookie to be set before they'll give you the download you request (for example websvn's server, tigris.org; see #24583). To accommodate this, port fetch should use a cookie jar.

For example, if I try to fetch websvn-2.3.1.tar.gz normally, it keeps redirecting back and forth between two URLs and the download never completes:

$ curl -L --max-redirs 10 -O http://websvn.tigris.org/files/documents/1380/47525/websvn-2.3.1.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   322  100   322    0     0    101      0  0:00:03  0:00:03 --:--:--   101
curl: (47) Maximum (10) redirects followed

But if I use a cookie jar, it works fine:

curl -c /tmp/cookiejar -L --max-redirs 10 -O http://websvn.tigris.org/files/documents/1380/47525/websvn-2.3.1.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  773k  100  773k    0     0  79601      0  0:00:09  0:00:09 --:--:-- 73025

I imagine fixing this in MacPorts would just entail a small addition to src/pextlib1.0/curl.c to create a temporary file, pass it to curl using the CURLOPT_COOKIEJAR option, and delete the temp file afterward.

Change History (3)

comment:1 Changed 15 years ago by raimue (Rainer Müller)

As we actually do not care which cookies are being set, we could use /dev/null as cookie jar.

comment:2 Changed 15 years ago by ryandesign (Ryan Carsten Schmidt)

Huh, I didn't expect that to work. I assumed it was setting a cookie, redirecting, then reading the cookie on the next page. But you're right, using /dev/null works for this site.

comment:3 Changed 15 years ago by raimue (Rainer Müller)

Resolution: fixed
Status: newclosed

The libcurl documentation says it attempts to write to the cookie jar on curl_easy_cleanup(), so it does not read or write to this file before.

Fixed in r66785.

Note: See TracTickets for help on using tickets.