cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: url string whitespace etc...

From: rick vaillancourt <rick_vaillancourt_at_hotmail.com>
Date: Wed, 06 Mar 2002 10:56:20 -0500

Thanks Daniel-

I tried that call yesterday before I pinged the group without success...

The following would be easier to read without word wrap, but
I have the hardcoded string that works, the string I replaced %20 to spaces
and the result after curl_escape. Can you tell me what I did
wrong?

Thanks much.

-Rick
//////////////////////////////////////////////

+this url works without calling curl_escape....

char VinInfoRequest::theURL[] =
"111.111.111.111/cgi-forte/fortecgi?pagename=&serviceName=abcd&XMLData=<?xml
%20version=\"1.0\"%20encoding=\"ISO-8859-1\"?><AutomobileQuote%20ComponentID
=\"2\"%20SystemID=\"CFN\"%20Jurisdiction=\"NH\"><ReferenceDataService%20Serv
iceID=\"3\"><GetVinInfo%20MethodID=\"4\"><VinInfoRequest%20RequestID=\"5\"><
VIN>12345678901234567</VIN></VinInfoRequest></GetVinInfo></ReferenceDataServ
ice></AutomobileQuote>";

+I replaced the %20s with space and then tried curl_escape...
I called it like this as doco said it calc'd the length if you passed 0

  char* pURL = curl_escape(inpURL, 0);

char VinInfoRequest::theURL[] =
"111.111.111.111/cgi-forte/fortecgi?pagename=&serviceName=abcd&XMLData=<?xml
version=\"1.0\" encoding=\"ISO-8859-1\"?><AutomobileQuote ComponentID=\"2\"
SystemID=\"CFN\" Jurisdiction=\"NH\"><ReferenceDataService
ServiceID=\"3\"><GetVinInfo MethodID=\"4\"><VinInfoRequest
RequestID=\"5\"><VIN>12345678901234567</VIN></VinInfoRequest></GetVinInfo></ReferenceDataSe
rvice></AutomobileQuote>";

+this is what I ended up with..., didnt work

111%2E111%2E111%2E111%2Fcgi%2Dforte%2Ffortecgi%3Fpagename%3D%26serviceName%3
Dqace1%26XMLData%3D%3C%3Fxml+version%3D%221%2E0%22+encoding%3D%22ISO%2D8859%
2D1%22%3F%3E%3CAutomobileQuote+ComponentID%3D%222%22+SystemID%3D%22CFN%22+Ju
risdiction%3D%22NH%22%3E%3CReferenceDataService+ServiceID%3D%223%22%3E%3CGet
VinInfo+MethodID%3D%224%22%3E%3CVinInfoRequest+RequestID%3D%225%22%3E%3CVIN%
3E12345678901234567%3C%2FVIN%3E%3C%2FVinInfoRequest%3E%3C%2FGetVinInfo%3E%3C
%2FReferenceDataService%3E%3C%2FAutomobileQuote%3E

>From: Daniel Stenberg <daniel_at_haxx.se>
>To: rick vaillancourt <rick_vaillancourt_at_hotmail.com>
>CC: curl-library_at_lists.sourceforge.net
>Subject: Re: url string whitespace etc...
>Date: Wed, 6 Mar 2002 08:56:20 +0100 (MET)
>
>On Tue, 5 Mar 2002, rick vaillancourt wrote:
>
> > I have a known url string that I have done hardcoded replacement of
>spaces
> > to %20 and quotes to /" etc...
> >
> > I have been looking, but have not found in the C api for a curl_... call
> > that would do this kind of substitution. I also checked the examples,
>but,
> > didn't find anything there either.
>
>It is called curl_escape(). Man page online is found here:
>http://curl.haxx.se/libcurl/c/curl_escape.html
>
>It is used like this:
>
> char *raw_string = " string with spaces ";
>
> char *url = curl_escape( raw_string, strlen(raw_string) );
>
> if(url) {
>
> printf("Converted: %s\n", url);
>
> free(url); /* not that the string must be freed after having been used
>*/
>
> }
>
>--
> Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
>
>
>

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
Received on 2002-03-06