• 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: URLAccess and Cookies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: URLAccess and Cookies


  • Subject: Re: URLAccess and Cookies
  • From: Zack Morris <email@hidden>
  • Date: Tue, 15 Jun 2004 01:25:40 -0600

On Jun 14, 2004, at 7:25 PM, Zack Morris wrote:

Hi, I am trying to send a cookie like this:

char myStr = "Cookie: PHPSESSID=5b591b121e419878f20b1f586e105738; path=/\r\n\r\n";
URLSetProperty( myRef, kURLHTTPRequestHeader, myStr, strlen( myStr ) );

However, when I connect to the server, it's like the request never finishes, and I never get a response from the server. Does anyone know how to format the header correctly so that I can set the cookie line? Here is an example in irc (I guess), I just don't know which fields I have to include, and don't really want to dig out the packet sniffer:

http://www.scriptaholics.com/node/view/339

Does someone have an example of URLSetProperty()? I can't find one for cookies anywhere on the net. Thanx,

Never mind, the problem was elsewhere. I had been checking for kURLCompletedState with URLGetCurrentState(), and then breaking out of my loop. However, the buffer I just got with URLGetBuffer() was filled, even though the download was finished, so I was breaking out prematurely without drawing that last buffer. And since the download fit in 1 buffer, I never saw it. It always pays to make a minimal test and draw EVERY byte that comes downstream, regardless of state!
As for cookies, they work perfectly. "Cookie: PHPSESSID=5b591b121e419878f20b1f586e105738" also works. If anyone is having trouble with these c strings, it's very important to pass the number of letters as the length and NOT INCLUDE THE TERMINATING 0. In other words, strlen( myStr ) is what is passed for the length in URLSetProperty(). That is, unless you are actually passing a pascal string, like in URLSetProperty( myRef, kURLUserName, myStr, myStr[0] + 1); If you are messing with cookies, the easiest way to send a cookie is copy the one right out of safari, even though you have to type it manually. Also, don't worry about looking at the cookie the server sends you at first, just try to send the one from safari and get the same page to come up that you see in safari. I am just saying all of this cuz I couldn't find the info on the net so now it is in the archives. This is on OS X 10.3, there is a possibility of failure in 8.6 <= os < 10.1. I think URLAccess works much better from 10.1 on. Thank you all for your help,

------------------------------------------------------------------------ ----
Zack Morris Z Sculpt Entertainment This Space
email@hidden http://www.zsculpt.com For Rent
------------------------------------------------------------------------ ----
If the doors of perception were cleansed, everything would appear to man as
it is, infinite. -William Blake, The Marriage of Heaven and Hell
_______________________________________________
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: NSURLConnection and self-signed certs? (From: "Wade Williams \(wwilliam\)" <email@hidden>)
 >URLAccess and Cookies (From: Zack Morris <email@hidden>)

  • Prev by Date: URLAccess and Cookies
  • Next by Date: Re: URLAccess and Cookies
  • Previous by thread: URLAccess and Cookies
  • Next by thread: Re: URLAccess and Cookies
  • Index(es):
    • Date
    • Thread