pokeb/asi-http-request — pull request #300 by yllan (2012-01-16 04:30:21+00:00)
Title: Redirect fix

Currently, the `requestRedirected` delegate method will be called right after the header is parsed. However, the data received delegate method which comes together with the redirected header will be called **after** the `requestRedirected` callback.

The sequence is like this:

1. HTTP Redirect Header
2. `requestRedirected`
3. HTTP Redirect Body (usually some simple html indicate the redirection)
4. `dataReceived`
5. HTTP Header
6. `headerReceived`
7. HTTP Body
8. `dataReceived`

I think in this sequence, step 4 may cause bugs. The delegate is most likely accumulating the received data for writing to file, live parsing, etc. Apparently, we should not append the data received from step 4 to step 8. The most straight forward thought is to "reset" the data status after the request being redirected but that actually happens before step 4.

I propose to move the step 2 between step 4 and 5.