for (auto& pattern : info.url_patterns)
if (pattern.MatchesURL(url))
return true;
+ return false;
}
- return false;
+ return true;
}
base::DictionaryValue* ExtractRequestInfo(net::URLRequest* request) {
void OnHeadersReceivedResponse(
const net::CompletionCallback& callback,
+ const net::HttpResponseHeaders* original_response_headers,
scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
const AtomNetworkDelegate::BlockingResponse& result) {
- if (result.responseHeaders.get())
- *override_response_headers = result.responseHeaders;
+ if (result.responseHeaders.get()) {
+ *override_response_headers = new net::HttpResponseHeaders(
+ original_response_headers->raw_headers());
+ void* iter = nullptr;
+ std::string key;
+ std::string value;
+ while (result.responseHeaders->EnumerateHeaderLines(&iter, &key, &value)) {
+ (*override_response_headers)->RemoveHeader(key);
+ (*override_response_headers)->AddHeader(key + ": " + value);
+ }
+ }
callback.Run(result.Cancel());
}
base::Bind(wrapped_callback, details),
base::Bind(&OnHeadersReceivedResponse,
callback,
+ original_response_headers,
override_response_headers));
return net::ERR_IO_PENDING;
details->Set("responseHeaders",
GetResponseHeadersDict(request->response_headers()));
details->SetBoolean("fromCache", request->was_cached());
+
+ auto response_headers = request->response_headers();
details->SetInteger("statusCode",
- request->response_headers() ?
- request->response_headers()->response_code() : 200);
+ response_headers ?
+ response_headers->response_code() : 200);
details->SetString("statusLine",
- request->response_headers() ?
- request->response_headers()->GetStatusLine() : std::string());
+ response_headers ?
+ response_headers->GetStatusLine() : std::string());
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(base::IgnoreResult(wrapped_callback),
details->Set("responseHeaders",
GetResponseHeadersDict(request->response_headers()));
details->SetBoolean("fromCache", request->was_cached());
+
+ auto response_headers = request->response_headers();
details->SetInteger("statusCode",
- request->response_headers() ?
- request->response_headers()->response_code() : 200);
+ response_headers ?
+ response_headers->response_code() : 200);
details->SetString("statusLine",
- request->response_headers() ?
- request->response_headers()->GetStatusLine() : std::string());
+ response_headers ?
+ response_headers->GetStatusLine() : std::string());
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(base::IgnoreResult(wrapped_callback),
* `filter` Object
* `urls` Array - A list of URLs or URL patterns. Request that cannot match any of the URLs
- will be filtered out.
+ will be filtered out.
* `listener` Function
* `details` Object
* `id` String - Request id.
* `blockingResponse` Object
* `cancel` Boolean - Whether to continue or block the request.
* `redirectURL` String **optional** - The original request is prevented from being sent or
- completed, and is instead redirected to the given URL.
+ completed, and is instead redirected to the given URL.
Fired when a request is about to occur. Should return a `blockingResponse`.
* `filter` Object
* `urls` Array - A list of URLs or URL patterns. Request that cannot match any of the URLs
- will be filtered out.
+ will be filtered out.
* `listener` Function
* `details` Object
* `id` String - Request id.
* `blockingResponse` Object
* `cancel` Boolean - Whether to continue or block the request.
* `requestHeaders` Object **optional** - When provided, request will be made with these
- headers.
+ headers.
Fired before sending an HTTP request, once the request headers are available. This may
occur after a TCP connection is made to the server, but before any http data is sent.
* `filter` Object
* `urls` Array - A list of URLs or URL patterns. Request that cannot match any of the URLs
- will be filtered out.
+ will be filtered out.
* `listener` Function
* `details` Object
* `id` String - Request id.
* `blockingResponse` Object
* `cancel` Boolean - Whether to continue or block the request.
* `responseHeaders` Object **optional** - When provided, the server is assumed to have
- responded with these headers.
+ responded with these headers.
Fired when HTTP response headers of a request have been received. Should return a
`blockingResponse`.
* `filter` Object
* `urls` Array - A list of URLs or URL patterns. Request that cannot match any of the URLs
- will be filtered out.
+ will be filtered out.
* `listener` Function
* `details` Object
* `id` String - Request id.
* `filter` Object
* `urls` Array - A list of URLs or URL patterns. Request that cannot match any of the URLs
- will be filtered out.
+ will be filtered out.
* `listener` Function
* `details` Object
* `id` String - Request id.