curl-library
Re: CURL custom POST commands
Date: Sat, 29 Aug 2015 01:30:53 -0400
On 8/28/2015 2:32 PM, Fitzgerald, Kevin wrote:
>
> **HTTP/1.1 200 OK
>
> Cache-Control: private, max-age=0
>
> Content-Type: text/xml; charset=utf-8
>
> Content-Encoding: gzip
>
> Vary: Accept-Encoding
>
> Server: Microsoft-IIS/7.5
>
> X-AspNet-Version: 2.0.50727
>
> Set-Cookie: ASP.NET_SessionId=sfmiyijxoyot1oub0sd2bb55; path=/; HttpOnly
>
> X-Powered-By: ASP.NET
>
> Date: Fri, 28 Aug 2015 18:14:09 GMT
>
> Content-Length: 568
>
> Received 919 bytes.
>
> * Closing connection #0
>
> The sysout says I am receiving 919 bytes from the web service. This is
> the same number of bytes I receive from the web service using a
> command line wgets sending the same data, so it appears that I am
> getting the expected response. But where is the rest of the data? It
> should have the following in the buffer as well:
>
> <?xml version="1.0" encoding="utf-8"?><soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:
>
> xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><checkCertificationsResponse
> xmlns="http://workweb.dwd.state.wi.us/KIDS/LicenseCertification/Service"><checkCertificat
>
> ionsResult><LicenseCertificationStatus><ssn>395555555</ssn><firstName>LARRY</firstName><lastName>MEDICINA</lastName><middleName>A</middleName><dateOfBirth>05/15/1965</d
>
> ateOfBirth><genderCode>M</genderCode><agencyCode>WDHF</agencyCode><licenseCategoryCode>PO</licenseCategoryCode><certified>Yes</certified><certificationReason>Delinquenc
>
> y</certificationReason><certificationStartDate>04/07/2010</certificationStartDate><uniqueRecordIdentifier>1</uniqueRecordIdentifier></LicenseCertificationStatus></check
>
> CertificationsResult></checkCertificationsResponse></soap:Body></soap:Envelope>
>
>
> Am I doing something wrong in my use of curl_easy_recv? From the
> description on the curl website, what I am doing looks correct, but
> then where is the data?
>
The content you are receiving from the server is compressed:
Content-Encoding: gzip
That means you will have to decompress the content or request that the
server not compress it. You should be able to do the latter by removing
the 'Accept-Encoding' header from your request. If the server still
sends you gzip you can try specifically requesting text with
'Accept-Encoding: identity'.
You've made an assumption that because the server is giving you 919
bytes that it must be the 919 bytes of XML that you expect to receive
(ie the xml quoted above). The size of the headers plus the size of the
content is 351 headers + 568 gzipped content = 919 bytes. It's just a
coincidence that the size is exactly the same size as the expected XML.
So your assumption is understandable but wrong. Unless you decompress
those 568 compressed bytes and parse the XML you won't know whether the
response is what you expected.
In this case you got lucky that the server response came all at once
which is why you got away with not calling curl_easy_recv repeatedly.
Please take a step back for a few minutes and consider some of the other
advice given to you this month and last month. One developer was even
nice enough to post an example you can use [1].
You are really missing out by using CURLOPT_CONNECT_ONLY. Its intended
purpose is custom protocols. You're going to waste a lot of time if you
continue that way. You are ignoring libcurl's ability to speak http and
trying to speak it yourself. As Daniel mentioned that's not good.
[1]: http://curl.haxx.se/mail/lib-2015-07/0109.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-08-29