Code review comment for lp:~abreu-alexandre/oxide/add-ua-to-downloadrequested

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Thanks for this.

Whilst it looks like this works for the case where a download triggered when we get "Content-Disposition: attachment" in the HTTP response, it probably won't work for downloads that are triggered from other sources (<anchor> download attribute) because net::URLRequest::GetFullRequestHeaders() only works once the request has been started.

In this case, the options are manually working out the user agent string (requires a call in to BrowserContextDelegate) or starting the request (perhaps just sending a HEAD request) and waiting for the response. But there are some issues with this:

- URLRequest is owned by the ResourceDispatcher, so you'd need to create a new one.
- You would also need to provide your own URLRequest::Delegate to drive the request.
- You only want to do this for requests that come via ResourceDispatcherHost::BeginDownload - perhaps checking ResourceRequestInfo::IsDownload()

Is there another mechanism that allows us to intercept and cancel a request once we get the initial response but before it reaches the download manager (where we don't have access to the URLRequest anyway), rather than relying on our extra API on ResourceDispatcherHostDelegate? We're calling this after receiving the initial response in the most common case anyway, so I'm starting to wonder whether this is really the best approach.

« Back to merge proposal