• 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
Returning custom NSURLResponse from NSURLProtocol
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Returning custom NSURLResponse from NSURLProtocol


  • Subject: Returning custom NSURLResponse from NSURLProtocol
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 02 Dec 2011 10:04:28 -0800

I’ve got an NSURLProtocol implementation for an HTTP-like protocol. I want it to return a custom NSHTTPURLResponse instance to the client. However, the initializer method for NSHTTPURLResponse was only added in iOS 5 / OS X 10.7.2. I’d like to at least be able to support OS X 10.6. Is there any way around this?

— I can’t call the inherited init method because it doesn’t let me specify the status code and response headers.

— I tried subclassing NSHTTPURLResponse and overriding -statusCode and -allHeaderFields to return my own values. This has the weird effect that, back on the main thread, the NSURLConnection delegate gets a _different_ response object that’s a direct instance of NSURLResponse.

—Jens

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Returning custom NSURLResponse from NSURLProtocol
      • From: "Quinn \"The Eskimo!\"" <email@hidden>
  • Prev by Date: Re: Prevent NSURLConnection retry
  • Next by Date: Re: Returning custom NSURLResponse from NSURLProtocol
  • Previous by thread: Re: Prevent NSURLConnection retry
  • Next by thread: Re: Returning custom NSURLResponse from NSURLProtocol
  • Index(es):
    • Date
    • Thread