HTTPS post with URLAccess
HTTPS post with URLAccess
- Subject: HTTPS post with URLAccess
- From: abhi nova <email@hidden>
- Date: Mon, 21 Mar 2005 05:35:07 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
I have been trying to submit a form (query string ) to a HTTPS server through POST method I am using URLAccess but I get -1 as return val for URLDownload and 7 as URLState from GetCurrentState();
someone told me there could be a problem with the server certificate.
OSStatus
CRegisterViaHTTP::DoPost(const char* inURL,
char* inURLEncodedQuery,
Size inQueryLength)
{
OSStatus status = noErr;
status = URLAccessAvailable();
if (!status)
{
return status;
}
URLReference urlRef;
status = URLNewReference( inURL, &urlRef);
// Load the urlReference with the POST data
// Specify the request method
char postMethod[] = "POST";
Size methodLength = strlen(postMethod);
status = URLSetProperty(urlRef,
kURLHTTPRequestMethod,
postMethod,
methodLength);
if (status != noErr)
{
return status;
}
char userAgent[] = ".*MSIE.*"; // c-string
Size userAgentLength =
strlen(userAgent);
status = URLSetProperty(urlRef,
kURLHTTPUserAgent,
userAgent,
userAgentLength);
if (status != noErr)
{
return status;
}
char contentType[] = "Content-Type:application/x-www-form-urlencoded"; // c-string
Size contentTypeLength = strlen(contentType);
status = URLSetProperty(urlRef,
kURLHTTPRequestHeader,
contentType,
contentTypeLength);
if (status != noErr)
{
return status;
}
// Specify the request body.
status = URLSetProperty(urlRef,
kURLHTTPRequestBody,
inURLEncodedQuery,
inQueryLength);
if(status != noErr)
{ //fatal
throw status;
}
// Download remote data into into memory, not a file.
FSSpec destination = { 0 };
Handle destinationHandle = NewHandle(0);
//URLOpenFlags openFlags = kURLDisplayProgressFlag | kURLDisplayAuthFlag;
URLOpenFlags openFlags = 0;
URLSystemEventProcPtr eventProc = RegURLCallbackProc;
void * userContext =
this;
status = URLDownload (urlRef,
&destination,
destinationHandle,
openFlags,
eventProc,
userContext);
//status = URLOpen(urlRef, NULL, kURLDisplayProgressFlag, NULL, kURLAllEventsMask, this);
URLState urlState = 0;
URLGetCurrentState(urlRef, &urlState);
URLGetError(urlRef, &status);
if (status != noErr)
{
return status;
}
char httpStatus[1024] = "";
// Convert return download data to a c-string.
UInt32 dataLength = GetHandleSize(destinationHandle);
if (!(dataLength > 0))
{
return MemError();
}
SetHandleSize(destinationHandle, dataLength + 1);
(*destinationHandle)[dataLength] = '\0';
// Check for HTTP status error codes.
// kURLHTTPRespHeader c-string.
// kURLStatusString Pascal string
status = URLGetProperty(urlRef,
kURLHTTPRespHeader,
httpStatus,
strlen(httpStatus));
if(status != noErr)
{
return status;
}
// Clean
up
DisposeHandle(destinationHandle);
status = URLDisposeReference(urlRef);
if (status != noErr)
{
return status;
}
return status;
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden