cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-users Mailing List Archives

[ curl-Bugs-669059 ] bug in content-type extracting

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Thu, 16 Jan 2003 06:22:02 -0800

Bugs item #669059, was opened at 2003-01-16 15:22
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=669059&group_id=976

Category: libcurl
Group: wrong content
Status: Open
Resolution: None
Priority: 5
Submitted By: Pavel Cenek (medvidek)
Assigned to: Daniel Stenberg (bagder)
Summary: bug in content-type extracting

Initial Comment:
   Hi,

   a found a bug in libCurl. 7.10.3. Let's say I
download an URI using curl_easy_perform and the
download is successful.

Then I want to get Content-Type header. I can use the
following code:

    char* contentType = NULL;
    if (curl_easy_getinfo (curlHandle,
CURLINFO_CONTENT_TYPE, &contentType)) {
// report error
    }
    else {
      // content-type in contentType or
contentType==NULL if not present
    }

However, if the http Content-Type header looks e.g.
like this:
Content-Type: text/html; charset=ISO-8859-4

contentType variable from the code above contains only
"text/html;"

The content type header is surely OK, because it is an
example taken from RFC2616 from chapter 14.17

The problem is in the file transfer.c in the following code

            /* check for Content-Type: header lines to
get the mime-type */
            else if (checkprefix("Content-Type:", k->p)) {
              char *start;
              char *end;
              int len;
              
              /* Find the first non-space letter */
              for(start=k->p+14;
                  *start && isspace((int)*start);
                  start++);

              /* count all non-space letters following */
/*
HERE IS THE BUG - WE SHOULD ACCEPT SPACES
TOO AND IGNORE ONLY TRAILING SPACES
*/
              for(end=start, len=0;
                  *end && !isspace((int)*end);
                  end++, len++);

              /* allocate memory of a cloned copy */
              data->info.contenttype = malloc(len + 1);
              if (NULL == data->info.contenttype)
                return CURLE_OUT_OF_MEMORY;

              /* copy the content-type string */
              memcpy(data->info.contenttype, start, len);
              data->info.contenttype[len] = 0; /* zero
terminate */
            }

   Sorry, if there is no bug and I just understand the
standard wrong. I am not member of curl mailing list,
so answer also to my email, please.

      medvidek

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

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=669059&group_id=976

-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com
Understand how to protect your customers personal information by implementing
SSL on your Apache Web Server. Click here to get our FREE Thawte Apache
Guide: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0029en
Received on 2003-01-16

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET