NSURLConnection and HTTP Headers
NSURLConnection and HTTP Headers
- Subject: NSURLConnection and HTTP Headers
- From: Drarok Ithaqua <email@hidden>
- Date: Mon, 15 Jan 2007 01:17:36 +0000
Hi list, hope this mail finds you all well.
I've been trying to debug some PHP code I've been working on that
returns custom HTTP headers, so I thought it would be nice to have a
tool to show the headers that are returned from various queries,
rather than using telnet to port 80. Possibly reinventing the wheel,
but I need the cocoa practise.
I've got a semi-working app insofar as it sends a request to the
server, and shows me the response, but I don't seem to be able to
access the returned headers.
I'm doing something like the following:
<code>
NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc]
initWithURL:[NSURL URLWithString:[urlField stringValue]]];
// Setting various options and custom request headers here...
NSData *urlData = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&urlResponse error:&urlError];
NSString *resultString = [NSString stringWithCString:[urlData bytes]
length:[urlData length]];
NSRunAlertPanel(@"Results", @"Results:\r\n%@\r\nLength:%d", @"OK",
nil, nil, resultString, [urlData length]);
</code>
I have tried accessing [urlRequest allHTTPHeaderFields], but that
returns the request headers.
I expected that urlResponse would have something useful in, but
looking at the docs for that class, it doesn't really DO anything?
Am I barking up the wrong tree with these classes? Would it be better
to roll my own code directly on top of sockets, or subclass
NSURLRequest in some way?
I'm just after some guidance, here.
Thanks in advance for any suggestions.
- Drarok
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden