OS X and URLAccess
OS X and URLAccess
- Subject: OS X and URLAccess
- From: ali raza <email@hidden>
- Date: Wed, 5 Nov 2003 02:12:38 -0800 (PST)
Hi,
Initially i posted this on carbon development list
with same subject . There were some great guys who
helped me eliminate most of the problems that i was
facing using POST with URLAccess but i am still
facing some problems. Back then i did not know that
there is a separate list for discussing mac network
programming issues. So here i am.
I am trying to POST data to an HTTPS URL using
URLAccess. Everytime i try to POST to an HTTPS URL
URLDownload gives error -1. I am using Mac OS X 10.2
and CodeWarrior 8.2. I know that URLAccess does not
support accessing HTTPS URLs via proxy server on OS X
(therefore, i am using dialup connection). Along
with that one needs to explicitly set the header
property with correct string (kURLHTTPRequestHeader
with
"Content-Type:application/x-www-form-urlencoded"). I
know that this has been fixed in panther. So
far i have successfully used GET on both HTTP/HTTPS
URLs and i can POST on HTTP URLs. But when it comes
to POSTing to HTTPS, my luck runs out. Following is
the code that i am using. Am i doing something
wrong?
Boolean CURLConnection :: URLOpenRequest(const char*
url)
{
errorCode=URLAccessAvailable();
errorCode=URLNewReference( url, &urlRef);
char postMethod[] = "POST";
Size methodLength = sizeof(postMethod);
errorCode=URLSetProperty(urlRef,kURLHTTPRequestMethod,
(void*) postMethod, methodLength);
char Header[] =
"Content-Type:application/x-www-form-urlencoded";
Size headerLength = sizeof(Header);
errorCode=URLSetProperty(urlRef,
kURLHTTPRequestHeader, (void *) Header, headerLength);
return errorCode;
}
Boolean CURLConnection :: URLSendRequest()
{
char QryStr[] = "crc=121&action=1&uid=abc&pwd=xyz";
Size QryStrSize = strlen(QryStr);
errorCode=URLSetProperty(urlRef,kURLHTTPRequestBody,
(void*)QryStr, QryStrSize);
errorCode =
URLDownload(urlRef,destination,destinationHandle,openFlags,NULL,userContext);
return errorCode;
}
CURLConnection :: CURLConnection()
{
errorCode=0;
destinationHandle=NewHandleClear(0);
destination=NULL;
//openFlags=kURLDisplayProgressFlag;
openFlags=kURLDisplayAuthFlag;
userContext=NULL;
downloadSize=0;
}
Thanks
Ali
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.