Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / September 2007



Tip: Looking for answers? Try searching our database.

overwrite/exchange NSHTTPCookieStorage

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alexander Clauss - 12 Sep 2007 21:53 GMT
Is it possible to overwrite or exchange the global NSHTTPCookieStorage
object that is used by the Cocoa URL loading system. I would prefer to
use my own private Cookie storage object so that the global cookies of
the default global Cookie storage are not deleted when my own
application deletes or modify its cookies.

Signature

Alexander

David Phillip Oster - 13 Sep 2007 04:06 GMT
> Is it possible to overwrite or exchange the global NSHTTPCookieStorage
> object that is used by the Cocoa URL loading system. I would prefer to
> use my own private Cookie storage object so that the global cookies of
> the default global Cookie storage are not deleted when my own
> application deletes or modify its cookies.

Yes. I believe there is sample code for this in

http://code.google.com/p/gdata-objectivec-client/

In GDataHTTPFetcher.m
Alexander Clauss - 13 Sep 2007 12:00 GMT
> Yes. I believe there is sample code for this in
>
> http://code.google.com/p/gdata-objectivec-client/
>
> In GDataHTTPFetcher.m

Thanks. They're not overwriting or exchanging the global cookie storage
of the system, they're just telling the URL loading system of Cocoa not
to handle Cookies (using the message setHTTPShouldHandleCookies of
NSURLRequest) and do their own cookie processing.

The only thing that has prevented me to do this so far is, that Apple
itself writes in the NSRequest.h header file that the message
"setHTTPShouldHandleCookies" is currently not implemented.

Signature

Alexander

David Phillip Oster - 14 Sep 2007 06:24 GMT
> > Yes. I believe there is sample code for this in
> >
[quoted text clipped - 10 lines]
> itself writes in the NSRequest.h header file that the message
> "setHTTPShouldHandleCookies" is currently not implemented.

I've tested that it does work in 10.4. If you can wait until next month,
when Leopard is expected to be released, you can see what the
NSRequest.h header file says then.
Alexander Clauss - 15 Sep 2007 00:43 GMT
> I've tested that it does work in 10.4. If you can wait until next month,
> when Leopard is expected to be released, you can see what the
> NSRequest.h header file says then.

Yes, it works in 10.4.

But there's still a big problem: All the cookies that are set via
JavaScript in WebView are not covered in this case. I've tried to
hook me into the global Cookie storage by writing a subclass of
NSHTTPCookieStorage and use this class via "poseAsClass" as a substitute
for the global NSHTTPCookieStorage object. But this doesn't really work.
The message "setCookies:forURL:mainDocumentURL:" is the only message
that gets called, but only for a small fraction of the cookies that are
really set and used. So it seems that Apple itself doesn't use the
public API of NSHTTPCookieStorage and instead uses some private API.

So it seems that there's no way to bypass the limitations of the
NSHTTPCookieStorage class of Cocoa by using a subclass or another cookie
storage object.

Signature

Alexander

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.