curl-library
Re: [PATCH] http: print reason phrase from HTTP status line on error
Date: Sat, 21 Jul 2012 12:51:10 +0200
Kamil Dudka <kdudka_at_redhat.com> wrote:
> Bug: https://bugzilla.redhat.com/676596
> diff --git a/lib/http.c b/lib/http.c
> index b421a2c..fd3999d 100644
> --- a/lib/http.c
> +++ b/lib/http.c
> @@ -2726,6 +2726,36 @@ static CURLcode header_append(struct SessionHandle *data,
>    return CURLE_OK;
>  }
>  
> +static void print_http_error(struct SessionHandle *data)
> +{
> +  struct SingleRequest *k = &data->req;
> +  char *beg = k->p;
> +
> +  /* make sure that data->req.p points to the HTTP status line */
> +  if(!strncmp(beg, "HTTP", 4)) {
> +
> +    /* skip to HTTP status code */
> +    beg = strchr(beg, ' ');
> +    if(beg && *++beg) {
> +
> +      /* find trailing CR */
> +      char *end = strchr(beg, '\r');
Maybe there should be a:
         if(!end)
           end = strchr(start, '\n');
here, to deal with the minority of servers that terminate
headers with a single LF. It would be consistent with other
parts of libcurl, for example copy_header_value().
Fabian
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
- application/pgp-signature attachment: signature.asc