diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index a361d747e6af..23bdc24cf761 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -18,6 +18,7 @@ #include "atom/common/native_mate_converters/image_converter.h" #include "atom/common/native_mate_converters/string16_converter.h" #include "atom/common/native_mate_converters/value_converter.h" +#include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "brightray/browser/inspectable_web_contents.h" #include "brightray/browser/media/media_stream_devices_controller.h" @@ -38,6 +39,7 @@ #include "native_mate/callback.h" #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" +#include "net/http/http_response_headers.h" #include "net/url_request/url_request_context.h" #include "atom/common/node_includes.h" @@ -310,6 +312,15 @@ void WebContents::DidStopLoading() { void WebContents::DidGetResourceResponseStart( const content::ResourceRequestDetails& details) { + net::HttpResponseHeaders* headers = details.headers.get(); + base::DictionaryValue response_headers; + void* iter = nullptr; + std::string key; + std::string value; + while (headers && headers->EnumerateHeaderLines(&iter, &key, &value)) { + response_headers.SetString(base::StringToLowerASCII(key), + base::StringToLowerASCII(value)); + } Emit("did-get-response-details", details.socket_address.IsEmpty(), details.url, @@ -317,7 +328,7 @@ void WebContents::DidGetResourceResponseStart( details.http_response_code, details.method, details.referrer, - details.header); + response_headers); } void WebContents::DidGetRedirectForResourceRequest( diff --git a/atom/common/native_mate_converters/value_converter.cc b/atom/common/native_mate_converters/value_converter.cc index 815ba0ebb211..7971623021a3 100644 --- a/atom/common/native_mate_converters/value_converter.cc +++ b/atom/common/native_mate_converters/value_converter.cc @@ -23,6 +23,13 @@ bool Converter::FromV8(v8::Isolate* isolate, } } +v8::Handle Converter::ToV8( + v8::Isolate* isolate, + const base::DictionaryValue& val) { + scoped_ptr converter(new atom::V8ValueConverter); + return converter->ToV8Value(&val, isolate->GetCurrentContext()); +} + bool Converter::FromV8(v8::Isolate* isolate, v8::Local val, base::ListValue* out) { diff --git a/atom/common/native_mate_converters/value_converter.h b/atom/common/native_mate_converters/value_converter.h index bb0ef66e719b..27e00f4521df 100644 --- a/atom/common/native_mate_converters/value_converter.h +++ b/atom/common/native_mate_converters/value_converter.h @@ -19,6 +19,8 @@ struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, base::DictionaryValue* out); + static v8::Handle ToV8(v8::Isolate* isolate, + const base::DictionaryValue& val); }; template<> diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index cc68f2008b9e..f7bc6396ecc7 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -674,11 +674,10 @@ Corresponds to the points in time when the spinner of the tab stops spinning. * `httpResponseCode` Integer * `requestMethod` String * `referrer` String -* `headers` String +* `headers` Object Emitted when details regarding a requested resource is available. `status` indicates the socket connection to download the resource. -`headers` is key-value string separated by new-line character. ### Event: 'did-get-redirect-request' diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index a1a472a5f154..96484649ceb8 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -333,11 +333,10 @@ Corresponds to the points in time when the spinner of the tab stops spinning. * `httpResponseCode` Integer * `requestMethod` String * `referrer` String -* `headers` String +* `headers` Object Fired when details regarding a requested resource is available. `status` indicates socket connection to download the resource. -`headers` is key-value string separated by new-line character. ### did-get-redirect-request