cURL
Haxx ad
libcurl

Shopping cart software, Online file storage, Online photo storage, Hosted shopping cart, Contact management software, Email marketing software, Project management software, Issue tracking software, Online notepad, Web publishing software

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-users Archives

BUG: redirect_url in write-out is not purged between requests

From: Stefan Pettersson <stefan_at_bigpointyteeth.se>
Date: Thu, 19 Nov 2009 11:30:26 +0100

Hi, I ran in to a small bug just now.

PROBLEM: curl remembers the value of the previous %{redirect_url} and outputs
it for every consecutive write-out even though no redirect was made for those
requests.

DESCRIPTION: curl is run via a conf file as below where the directory upload/
exists at the remote host but foo/ and bar/ does not. The request to "upload"
lacks a final slash and will thus be redirected to http://192.168.111.2/upload/
via a Location header and this redirect URL will be present in the
%{redirect_url} on write-out. This variable is not purged between requests and
is therefore shown for upcoming requests as well.

    # test.conf
    silent
    write-out = "%{http_code}\t%{size_download}\t%{num_redirects}\t%{url_effective}\t %{redirect_url}\n"

    output = 200
    url = http://192.168.111.2/foo
    output = 200
    url = http://192.168.111.2/bar
    output = 200
    url = http://192.168.111.2/upload
    output = 200
    url = http://192.168.111.2/foo
    output = 200
    url = http://192.168.111.2/bar

Here's an example:

$ curl --config test.conf
404 320 0 http://192.168.111.2/foo
404 320 0 http://192.168.111.2/bar
301 355 0 http://192.168.111.2/upload http://192.168.111.2/upload/
404 320 0 http://192.168.111.2/foo http://192.168.111.2/upload/ <-- here
404 320 0 http://192.168.111.2/bar http://192.168.111.2/upload/ <-- and here
$ tail /var/log/apache2/access_log
192.168.111.2 - - [19/Nov/2009:11:12:56 +0100] "GET /foo HTTP/1.1" 404 320 "-" "curl/7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.10"
192.168.111.2 - - [19/Nov/2009:11:12:56 +0100] "GET /bar HTTP/1.1" 404 320 "-" "curl/7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.10"
192.168.111.2 - - [19/Nov/2009:11:12:56 +0100] "GET /upload HTTP/1.1" 301 355 "-" "curl/7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.10"
192.168.111.2 - - [19/Nov/2009:11:12:56 +0100] "GET /foo HTTP/1.1" 404 320 "-" "curl/7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.10"
192.168.111.2 - - [19/Nov/2009:11:12:56 +0100] "GET /bar HTTP/1.1" 404 320 "-" "curl/7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.10"
$ uname -a
Linux er 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:48:10 UTC 2009 i686 GNU/Linux
$ curl -V
curl 7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.10
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

Cheers and thanks for a great tool!

-- 
Stefan Pettersson
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2009-11-19

These mail archives are generated by hypermail.

donate! Page updated November 16, 2009.
web site info

File upload with ASP.NET