• 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: Sat, 8 Nov 2003 01:51:45 -0800 (PST)

Eli,
I have already done this but still no use. I guess
this is not the problem. I just mentioned it because i
thought i might be missing something.

Thanks
Ali

--- Eli Green <email@hidden> wrote:
> What this means is that sizeof() will return 5,
> because this line:
>
> char postMethod[] = "POST";
>
> creates an array of 5 characters, the last character
> being NULL.
> Whereas strlen() will return 4, because strlen stops
> counting when it
> hits a NULL. You should probably use strlen()
> anyway, in case you ever
> pass in a string that isn't constant-length
> (character pointer).
>
> The same probably goes for headerLength too.
>
> The short answer is: replace sizeof(postMethod) with
>
> strlen(postMethod). Do the same with sizeof(Header).
>
> Wether that's actually your problem or not, I'm not
> sure.
>
> On Friday, Nov 7, 2003, at 06:23 Canada/Eastern, ali
> raza wrote:
>
> > 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,userCon
>
> > text);
> > 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.
> >
>


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

References: 
 >Re: OS X and URLAccess (From: Eli Green <email@hidden>)

  • Prev by Date: [FOUND] Mac OS X Mach-O BSD C PowerPlant (was Re: OpenTransport behaviour under X)
  • Next by Date: Re: How to POST using CFSocket
  • Previous by thread: Re: OS X and URLAccess
  • Next by thread: Repost: OpenTransport problems under X
  • Index(es):
    • Date
    • Thread