|
@@ -33,6 +33,28 @@
|
|
|
#include "shell/common/node_includes.h"
|
|
|
#include "shell/common/promise_util.h"
|
|
|
|
|
|
+namespace mate {
|
|
|
+
|
|
|
+template <>
|
|
|
+struct Converter<std::pair<std::string, std::string>> {
|
|
|
+ static v8::Local<v8::Value> ToV8(
|
|
|
+ v8::Isolate* isolate,
|
|
|
+ const std::pair<std::string, std::string>& pair) {
|
|
|
+ mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
|
|
+ dict.Set("key", base::ToLowerASCII(pair.first));
|
|
|
+ dict.Set("value", pair.second);
|
|
|
+ return dict.GetHandle();
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+} // namespace mate
|
|
|
+
|
|
|
+namespace electron {
|
|
|
+
|
|
|
+namespace api {
|
|
|
+
|
|
|
+namespace {
|
|
|
+
|
|
|
class BufferDataSource : public mojo::DataPipeProducer::DataSource {
|
|
|
public:
|
|
|
explicit BufferDataSource(base::span<char> buffer) {
|
|
@@ -200,12 +222,6 @@ class JSChunkedDataPipeGetter : public gin::Wrappable<JSChunkedDataPipeGetter>,
|
|
|
gin::WrapperInfo JSChunkedDataPipeGetter::kWrapperInfo = {
|
|
|
gin::kEmbedderNativeGin};
|
|
|
|
|
|
-namespace electron {
|
|
|
-
|
|
|
-namespace api {
|
|
|
-
|
|
|
-namespace {
|
|
|
-
|
|
|
const net::NetworkTrafficAnnotationTag kTrafficAnnotation =
|
|
|
net::DefineNetworkTrafficAnnotation("electron_net_module", R"(
|
|
|
semantics {
|
|
@@ -343,6 +359,10 @@ mate::WrappableBase* SimpleURLLoaderWrapper::New(mate::Arguments* args) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Chromium filters headers using browser rules, while for net module we have
|
|
|
+ // every header passed.
|
|
|
+ request->report_raw_headers = true;
|
|
|
+
|
|
|
v8::Local<v8::Value> body;
|
|
|
v8::Local<v8::Value> chunk_pipe_getter;
|
|
|
if (opts.Get("body", &body)) {
|
|
@@ -419,8 +439,12 @@ void SimpleURLLoaderWrapper::OnResponseStarted(
|
|
|
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate());
|
|
|
dict.Set("statusCode", response_head.headers->response_code());
|
|
|
dict.Set("statusMessage", response_head.headers->GetStatusText());
|
|
|
- dict.Set("headers", response_head.headers.get());
|
|
|
dict.Set("httpVersion", response_head.headers->GetHttpVersion());
|
|
|
+ // Note that |response_head.headers| are filtered by Chromium and should not
|
|
|
+ // be used here.
|
|
|
+ DCHECK(response_head.raw_request_response_info);
|
|
|
+ dict.Set("rawHeaders",
|
|
|
+ response_head.raw_request_response_info->response_headers);
|
|
|
Emit("response-started", final_url, dict);
|
|
|
}
|
|
|
|