• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: OS X and URLAccess
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OS X and URLAccess


  • Subject: Re: OS X and URLAccess
  • From: ali raza <email@hidden>
  • Date: Fri, 7 Nov 2003 03:23:30 -0800 (PST)

Hey come on guys is it that tough that no one can
answer this question. This mailing list is for solving
peoples problems relating to mac networking or atleast
try to solve but no one is even trying. Unfortunately
i am at the receiving end so help me out please.

A gentleman, at some other mailing list told me this.

> You have an off by one bug with the assumption that
> sizeof(postMethod) == strlen(postMethod)
>
> Your code adds a extraneous null character to the
URL stream
>
> > char postMethod[] = "POST";
> > Size methodLength = sizeof(postMethod);
> ^^^^^^^
> >
errorCode=URLSetProperty(urlRef,kURLHTTPRequestMethod,
> > (void*) postMethod, methodLength);
>
>
> Assert_(sizeof(postMethod) == strlen(postMethod));
// assumed
> Assert_(sizeof(postMethod) == strlen(postMethod)+1);
// reality

I tried it but no use. May be i am doing it the wrong
way. What is the correct way to do the above thing.
I wonder what this means.
=========
Previously the question was

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;
}


__________________________________
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.

  • Follow-Ups:
    • Re: OS X and URLAccess
      • From: Eli Green <email@hidden>
  • Prev by Date: How to POST using CFSocket
  • Next by Date: Re(2): Proxy Tunneling (via the HTTP CONNECT method)
  • Previous by thread: OS X and URLAccess
  • Next by thread: Re: OS X and URLAccess
  • Index(es):
    • Date
    • Thread