cURL / Mailing Lists / curl-library / Single Mail

curl-library

problems following redirect

From: Nilsson Johan <EXT-Johan.Nilsson_at_nokia.com>
Date: Fri, 11 May 2001 12:26:29 +0200

Hello!

I'm using (the GREAT!) libcurl and I'm having problems with a server
doing redirect and I don't really know how to handle it. I will be able
to handle this type of redirect...

I've set the following options:
* curl_easy_setopt(mCurlHandle, CURLOPT_FAILONERROR, 0);
* curl_easy_setopt(mCurlHandle, CURLOPT_FOLLOWLOCATION, 1);
* curl_easy_setopt(mCurlHandle, CURLOPT_VERBOSE, 1);
* curl_easy_setopt(mCurlHandle, CURLOPT_MAXREDIRS, 5);

Let's say that the url is http://www.something.com/files/1.2.3.jpg. I
let libcurl dump the headers using curl_easy_setopt(mCurlHandle,
CURLOPT_HEADER, 1) just so that I can have a look at what happens.

The server's response is as follows:
----------------------------
HTTP/1.1 302 Moved Temporarily
Server: Netscape-Enterprise/4.1
Content-Length: 0
Location: /uploaded_files/slindberg.jpg
Via: 1.1 xx.nokia.com (NetCache 4.1R6D4)
Date: Fri, 11 May 2001 10:02:42 GMT

HTTP/1.1 404 Not found
Server: Netscape-Enterprise/4.1
Content-type: text/html; charset=iso-8859-1
Content-Length: 207
Via: 1.1 xx.nokia.com (NetCache 4.1R6D4)
Date: Fri, 11 May 2001 10:02:43 GMT

<TITLE>Not Found</TITLE><H1>Not Found</H1> The requested object does not
exist on this server. The link you fo
llowed is either outdated, inaccurate, or the server has been instructed
not to let you have it.
-----------------------------

The file is actually located at
http://www.something.com/uploaded_files/slindberg.jpg but libcurl only
give me the above file and does probably not follow the location.

The printout from libcurl is as follows (stripped down):
> GET http://www.something.com/files/1.2.3.jpg HTTP/1.0
Host: www.something.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*

* Follows Location: to new URL: 'http://www.something.com/files/'
> GET http://www.something.com/files/ HTTP/1.0
User-Agent: Mozilla/5.0 (X11; U; Linux 2.2.16-3 i686; en-US; m18)
Gecko/20010215 OST
Host: www.something.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*

Any ideas? I'm stuck.

//Johan

_______________________________________________
Curl-library mailing list
Curl-library_at_lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/curl-library
Received on 2001-05-11