Howto: send cookies/customize HTTP request headers?
Howto: send cookies/customize HTTP request headers?
- Subject: Howto: send cookies/customize HTTP request headers?
- From: Axel Behr <email@hidden>
- Date: Wed, 14 Nov 2001 16:10:40 +0100
Hi!
I'm, like some, new to Cocoa, coming from Java, and decided to start
writing my first own Cocoa program, after having done half a dozen
tutorials or so ;)
The program I have in mind needs to be able to send cookies to web
servers. I have done a prototype in rebol (sort of a functional network
scripting language, for those who don't know) which works fine but lacks
a GUI (and I don't want to invest time in REBOLview). I have written
some programs in Java that do other stuff with web servers like
uploading files and https (where I used a really nice alternate
implementation of http that allowed for most tricks already), so I at
least have a basic technical understanding of what I am wanting ;)
I know, I could possibly find a solution by combining the powers of Java
and Objective-C, but I would rather use [Objective-]C[++] only, since I
don't want to spend user time launching VMs, and I WANT to get to know
more about Cocoa anyway ;)
So, to begin with, it was hard for me to find my way into the APIs on X,
since there seemed to be alternatives of (almost) functional
equivalence, esp. since JDK and rebol are in a way legacy free ;). All I
knew was, I wanted to use Cocoa and get as much done for me [by
frameworks] as possible ;)
I stumbled over three discrete portions of the X Api, that somewhat
seemed related to my task:
+ URL Access Manager (which is quite "Pascalish" ;) and seems to me only
supported for legacy reasons)
+ Core Foundation (CFURL, etc - with almost undocumented structures like
CFDataRef, which worked for me and is approachable, but isn't OO, as I
see it, and somehow seems to be most suitable for cross platform work,
which I am not interested in doing now, esp. since the other platforms
seem to be Mac OS 8/9, GnuSTEP[?] and Darwin, of which the Intel version
would hypothetically function on one out of a few dozen machines only
anyway, right now)
+ NSString/NSURL from Foundation, which seemed a natural candidate,
because they are quite similar in richness to what I am used to from Java
Anyway, looking into the headers and documentation for
NSURL/NSURLHandle, i didn't see a way to insert anything into the HTTP
header being generated. I also took a plunge into the code of the Omni
OWF, where I found the precise place where header generation happens,
but their code is tied closely together (i.e. lots of classes needed)
and really more suited for browsers (or, whatever, far too complex for
me, and it lacks documentation, too).
Then, I have been going through the recent discussions concerning NSURL
in this group, and I found lots of postings (mem leaks, etc, I know I
need to be careful right now :) but nothing header/cookie related.
So far, all I have is code along the lines of
myURL = [NSURL URLWithString:kURL];
inp = [NSString stringWithContentsOfURL:myURL];
which isn't much really ;)
It is hard for me to find out, how the NSURL class implements protocols,
and I fear, that as opposed to JDK, where most all of the classes are
available in source as well as kindof nicely documented in Javadoc or
O'Reilly books ;), I need to learn a lot of other techniques in order to
find out what's really happening. I know, there are ways to "extend"
existing classes, but I really need more pointers into how networking
works in Foundation/Cocoa (books, online help, source). Any input for
this would be really appreciated ;))
As well, I am missing coherency in frameworks and documentation. E.g. I
know, I can call C, and will probably find tons of network code in the
GNU/Unix area, but, sigh, excuse me, I have become quite used to never
leave my objects' world :) (anyone knows of wrappers?)
I so far have the impression, that Apple's programmers this year did a
hell of a good job with 10.1, igniting my interest in writing to it
(btw. 10.1.1 works even better for me since yesterday night ;), but left
documentation as something to happen in the future :(
I know, JDK did _evolve_ documentation-wise, and I remember how much I
struggled with it in the beginning, but the Inside Macintosh tradition
doesn't seem to continue in the current docs right now.
O.k., enough whining for now. Cocoa is certainly worth the effort, it is
just that this has to happen in my spare time ;)
Thanks for listening,
Axel
PS: Can please anyone tell me how to search within views of Help Viewer
(like: Command-F)? I can load the documentation in Explorer, but some
links still throw me back to Help Viewer, sigh.
PPS: I only found out about F5 in PB two days ago (for someone using
JBuilder as a main work tool!!! I am having PB installed for over a year
now... The key binding sucks, since I am on a Ti and have to use the
fn-key to access it -- I know, I can change it, but why doesn't someone
at Apple look at how intuitively JBuilder handles this right out of the
box?). Does anyone know more of these tricks (more code-insight-like
features etc.)?