cURL / Mailing Lists / curl-users / Single Mail

curl-users

[ curl-Bugs-426442 ] FAILONERROR does not set HTTP_CODE

From: <noreply_at_sourceforge.net>
Date: Tue, 22 May 2001 13:52:43 -0700

Bugs item #426442, was updated on 2001-05-22 13:52
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=100976&aid=426442&group_id=976

Category: libcurl
Group: bad behaviour
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Daniel Stenberg (bagder)
Summary: FAILONERROR does not set HTTP_CODE

Initial Comment:
libcurl 7.7.3
If the option CURLOPT_FAILONERROR is set and an error
occurs, the code returned by getinfo(CURLINFO_HTTP_CODE) is zero (or the value from the previous transaction) since the library fails to set it.

Here is the relevant code from transfer.c:
if (2 == sscanf (p, " HTTP/1.%d %3d", &httpversion,
                 &httpcode)) {
  /* 404 -> URL not found! */
  if (
      ( ((data->bits.http_follow_location) &&
         (httpcode >= 400))
        ||
        (!data->bits.http_follow_location &&
         (httpcode >= 300)))
       && (data->bits.http_fail_on_error)) {
   /* If we have been told to fail hard on HTTP-errors,
      here is the check for that: */
   /* serious error, go home! */
   failf (data, "The requested file was not found");
   return CURLE_HTTP_NOT_FOUND;
   }
data->progress.httpcode = httpcode;
data->progress.httpversion = httpversion;
...

If you duplicate the two lines:
   data->progress.httpcode = httpcode;
   data->progress.httpversion = httpversion;
just before the:
   return CURLE_HTTP_NOT_FOUND;
then the code will be available to the application.

----------------------------------------------------------------------

You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=100976&aid=426442&group_id=976
Received on 2001-05-22