Hello,

When netlib processes a "301 Moved Permanently" response from the web
server, it sets up a replacement channel instead of the current one,
runs the new channel and cancels the old one (at the same time also
cancelling the current transaction and moving the socket used from the
"active" to the "idle" list).

During the process, netlib calls OnStartRequest(), but somehow knows
not to call OnDataAvailable() and OnStopRequest(), which I can't quite
understand.  I am trying to handle a "426 Upgrade Required" response
and repeat the same things, but in my case OnDataAvailable() and
OnStopRequest() are called, which I believe causes one of them to
return an error, dooming any subsequent actions.

The logging output during handling a 301 response shows a function call
order like this:
...
...
nsHttpChannel::OnStartRequest   -->after receiving the 301 response
nsHttpChannel::ProcessResponse
nsHttpChannel::ProcessRedirection
nsHttpHandler::NewURI
nsIOService::NewChannelFromURI
nsHttpHandler::NewChannel
nsHttpHandler::NewProxiedChannel
nsHttpChannel::Init
nsHttpHandler::SetupReplacementChannel
nsHttpHandler::AddStandardRequestHeader
nsHttpChannel::AsyncOpen
nsHttpChannel::Connect
nsHttpChannel::SetupTransaction
nsHttpConnectionMgr::AddTransaction
nsSocketTransportService::PostEvent         --> posting the
OnMsgNewTransaction event
nsHttpChannel::Cancel                              --> cancel old
channel...
nsHttpConnectionMgr::CancelTransaction   --> ...and the old transaction
nsSocketTransportService::PostEvent         --> posting the
OnMsgCancelTransaction event
nsSocketTransportService::PostEvent
nsHttpConnectionMgr::OnMsgNewTransaction
...    --> proceeding with the new request

I am trying to do the same thing as in ProcessRedirection(), calling:

NewChannelFromURI()
SetupReplacementChannel()
AsyncOpen() on the new channel

My logging output looks very similar, but in the very end I see that
OnDataAvailable() and StopRequest() are called before
OnMsgNewTransaction().

Does anybody know why during a redirection processing OnDataAvailable()
and StopRequest() wouldn't get called, but when I am trying to do the
same thing they do?

Do you think it might have to do something with the status code of the
HTTP response - for example netlib would know how to handle a 301
response, but it wouldn't know how to handle a 426 Upgrade Required
response, which is what I am implementing?  I implemented handling the
426 status code in nsHttpChannel::ProcessResponse() and
nsHttpResponseHead::MustValidate(), but can anybody think of any more
changes needed to handle this new status code?

_______________________________________________
dev-tech-network mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-network

Reply via email to