curl-library
Re: using libcurl for ipp
Date: Fri, 19 Sep 2008 15:19:54 -0500
On Thu, Sep 18, 2008 at 7:15 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Tue, 9 Sep 2008, benoy m wrote:
>
> I was wondering if anybody has used libcurl for Internet Printing
>> Protocol. If so can you point me in the right direction to get started.
>>
>
> IPP is "over HTTP" so I figure you can easily just tell libcurl to send the
> protocol data to the server!
>
> --
>
> / daniel.haxx.se
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);
Then I create the response headers:
curl_slist* responseHeaders = NULL ;
responseHeaders = curl_slist_append( responseHeaders , "Expect: " ) ;
responseHeaders = curl_slist_append( responseHeaders ,
"Transfer-Encoding: chunked" ) ;
responseHeaders = curl_slist_append( responseHeaders , "Content-Type:
application/ipp" ) ;
curl_easy_setopt( handle , CURLOPT_HTTPHEADER , responseHeaders );
Then curl_easy_perform is called.
However, I kept getting "HTTP/1.1 400 Bad Request" from the print server.
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.
So, since the Content-Type for ipp is, application/ipp, i did
curl_easy_setopt(handle, CURLOPT_POST, 0). But when i do this the request
becomes a GET instead of a POST.
Is there anything that I am doing wrong with libcurl? Sorry if I am not
using the functions properly, I am new to libcurl and c.
Thanks,
benoy
Received on 2008-09-19