cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: using libcurl for ipp

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 19 Sep 2008 22:56:38 +0200 (CEST)

On Fri, 19 Sep 2008, benoy m wrote:

> So I have built the http request data for content type: application/ipp and
> store it as a byte array.
> vector<unsigned char> postdata;
>
> Then I make the following calls:
> curl_easy_setopt( handle, CURLOPT_POSTFIELDSIZE, postdata.size());
> curl_easy_setopt( handle, CURLOPT_POSTFIELDS , &postdata);

CURLOPT_POSTFIELDS expects a plain C char *, so I hope your C++isms convert it
to such a one.

> Then I create the response headers:

No, libcurl is a client it sends request headers.

> responseHeaders = curl_slist_append( responseHeaders ,
> "Transfer-Encoding: chunked" ) ;

chunked encoding will be wrong and downright confusing, you already provide
the expected size of the POST.

> responseHeaders = curl_slist_append( responseHeaders , "Content-Type:
> application/ipp" ) ;
>
> However, I kept getting "HTTP/1.1 400 Bad Request" from the print server.

And no hints at all from the server what the problem is?

> So I have read a little more and found that using CURLOPT_POSTFIELDS sets
> Content-Type to application/x-www-form-urlencoded by default in the header.

Yes, but your Content-Type: header replacement change that.

> So, since the Content-Type for ipp is, application/ipp, i did
> curl_easy_setopt(handle, CURLOPT_POST, 0).

You still want it to be a POST. Or?

And I would really recommend using CURLOPT_DEBUGFUNCTION (see the debug.c
example) to get to see exactly what libcurl sends and receives.

-- 
  / daniel.haxx.se
Received on 2008-09-19