title: NSUrlConnection conection:didReceiveResponse not being called during HTTP 302 redirects
body: <p>I have a class that implements <code>NSURLProtocol</code> and initiates a new <code>NSURLConnection</code> in <code>startLoading</code> method. I also need the HTTP responses for all requests, so I do this by implementing data delegate method <code>connection:didReceiveResponse</code>. For HTTP redirects, I also implement <code>connection:willSendRequest:redirectResponse:</code> wherein I call the NSURLProtocolClient Method for redirects. Below is the code</p>
  
  <pre><code>(NSURLRequest *)connection:(NSURLConnection *)connection
               willSendRequest:(NSURLRequest *)request
               redirectResponse:(NSURLResponse *)response {
      if (response) {
          [self.client URLProtocol:self 
            wasRedirectedToRequest:request 
                  redirectResponse:response];
      }
  
      return request;
  }
  </code></pre>
  
  <p>The problem with this code is <code>connection:didReceiveResponse</code> never gets called when redirectResponse is not <code>nil</code>. When I comment out the protocol client's <code>URLProtocol:wasRedirectedToRequest:redirectResponse</code> method, <code>connection:didReceiveResponse</code> starts getting called again.</p>
  
  <p>I am not sure what's going on here. Can anybody shed some light on this behavior ?</p>