feat: migrate protocol module to NetworkService (Part 11) (#18706)
* Pipe data into HTTP protocol handlers * Remove unused parameters * Remove "sending request of http protocol urls" test Sending request to "http://" in "file://" violates CORS rules and always fail, before NetworkService somehow Chromium still sent a request even though the request failed with CORS error, so the test passes while the test is not valid. With NetworkService no request is sent at all and the test jsut fails. So this is an ancient invalid test, as sending http requests have been fully covered in other tests, I am removing this test.
This commit is contained in:
parent
c6dc7d5b79
commit
3a1d6d2ce1
6 changed files with 190 additions and 34 deletions
|
@ -12,6 +12,7 @@
|
|||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/net/asar/asar_url_loader.h"
|
||||
#include "atom/browser/net/node_stream_loader.h"
|
||||
#include "atom/browser/net/url_pipe_loader.h"
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
|
@ -248,8 +249,8 @@ void AtomURLLoaderFactory::StartLoading(
|
|||
std::move(loader), routing_id, request_id, options, new_request,
|
||||
std::move(client), traffic_annotation);
|
||||
} else {
|
||||
StartLoadingHttp(std::move(loader), routing_id, request_id, options,
|
||||
new_request, std::move(client), traffic_annotation,
|
||||
StartLoadingHttp(std::move(loader), new_request, std::move(client),
|
||||
traffic_annotation,
|
||||
mate::Dictionary::CreateEmpty(args->isolate()));
|
||||
}
|
||||
return;
|
||||
|
@ -275,8 +276,8 @@ void AtomURLLoaderFactory::StartLoading(
|
|||
std::move(head), dict, args->isolate(), response);
|
||||
break;
|
||||
case ProtocolType::kHttp:
|
||||
StartLoadingHttp(std::move(loader), routing_id, request_id, options,
|
||||
request, std::move(client), traffic_annotation, dict);
|
||||
StartLoadingHttp(std::move(loader), request, std::move(client),
|
||||
traffic_annotation, dict);
|
||||
break;
|
||||
case ProtocolType::kStream:
|
||||
StartLoadingStream(std::move(loader), std::move(client), std::move(head),
|
||||
|
@ -358,21 +359,18 @@ void AtomURLLoaderFactory::StartLoadingFile(
|
|||
// static
|
||||
void AtomURLLoaderFactory::StartLoadingHttp(
|
||||
network::mojom::URLLoaderRequest loader,
|
||||
int32_t routing_id,
|
||||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& original_request,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
|
||||
const mate::Dictionary& dict) {
|
||||
network::ResourceRequest request;
|
||||
request.headers = original_request.headers;
|
||||
request.cors_exempt_headers = original_request.cors_exempt_headers;
|
||||
auto request = std::make_unique<network::ResourceRequest>();
|
||||
request->headers = original_request.headers;
|
||||
request->cors_exempt_headers = original_request.cors_exempt_headers;
|
||||
|
||||
dict.Get("url", &request.url);
|
||||
dict.Get("referrer", &request.referrer);
|
||||
if (!dict.Get("method", &request.method))
|
||||
request.method = original_request.method;
|
||||
dict.Get("url", &request->url);
|
||||
dict.Get("referrer", &request->referrer);
|
||||
if (!dict.Get("method", &request->method))
|
||||
request->method = original_request.method;
|
||||
|
||||
scoped_refptr<AtomBrowserContext> browser_context =
|
||||
AtomBrowserContext::From("", false);
|
||||
|
@ -392,9 +390,10 @@ void AtomURLLoaderFactory::StartLoadingHttp(
|
|||
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory =
|
||||
content::BrowserContext::GetDefaultStoragePartition(browser_context.get())
|
||||
->GetURLLoaderFactoryForBrowserProcess();
|
||||
url_loader_factory->CreateLoaderAndStart(
|
||||
std::move(loader), routing_id, request_id, options, std::move(request),
|
||||
std::move(client), traffic_annotation);
|
||||
new URLPipeLoader(
|
||||
url_loader_factory, std::move(request), std::move(loader),
|
||||
std::move(client),
|
||||
static_cast<net::NetworkTrafficAnnotationTag>(traffic_annotation));
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue