Extending URL Loading System - NSURLResponse
Extending URL Loading System - NSURLResponse
- Subject: Extending URL Loading System - NSURLResponse
- From: Aurora Phoenix <email@hidden>
- Date: Thu, 09 Oct 2008 21:05:28 -0700
- Thread-topic: Extending URL Loading System - NSURLResponse
Hi!
Due to strict requirements I am unfortunately unable to discuss openly, I am
forced to implement low-level transport to an HTTP server. The app
originally uses NSURLConnection, e.g.
reply = [NSURLConnection sendSynchronousRequest: req
returningResponse: &resp
error: &err];
Basically, I¹d like to make a dynamically configurable way (depending on my
network connection/location) to alter the behaviour of NSURLConnection. I am
guessing I can do this part pretty quickly by a switch or if/else that in
some cases uses the original above code or in others uses
MyCustomURLConnection. Now I can get my new class to work with NSURLRequest
(took less than 30 minutes, thanks Objective-C++!)... Cool. NSError? No
problem.
When I looked at NSHTTPURLResponse, however, there didn¹t seem to be a way
to dynamically build one of these suckers! Unlike
NSURLRequest/NSMutableURLRequest, there isn¹t NSMutableHTTPResponse;
examining the headers, I find an opaque (private/internal) class as the sole
member of NSHTTPURLResponse.
What would be the recommended way (s) to deal with this situation? I
basically want MyCustomURLConnection to returns something like a
MyCustomHTTPResponse (actually, I¹d prefer to return a standard
NSURLResponse but one that I¹ve custom built the headers, status and body of
(well body not really a problem since it¹s returned). As there are no
mutators for NSURLResponse and it looks to be a ³sealed² class... Hmm. I was
thinking subclassing MyCustomHTTPResponse from NSURLResponse ... And then
any subsequent processing (which should be the same regardless of transport)
works perfectly well with an NSURLResponse and should with the new class.
Thoughts?
TIA and Cheers!
APD
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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