]> khamidou — GitHub mirrors - electron.git/commitdiff
return headers as object
authordeepak1556 <hop2deep@gmail.com>
Thu, 21 May 2015 21:22:52 +0000 (02:52 +0530)
committerdeepak1556 <hop2deep@gmail.com>
Sat, 23 May 2015 13:56:47 +0000 (19:26 +0530)
atom/browser/api/atom_api_web_contents.cc
atom/common/native_mate_converters/value_converter.cc
atom/common/native_mate_converters/value_converter.h
docs/api/browser-window.md
docs/api/web-view-tag.md

index a361d747e6af6eae82e8df0a22efc556321ad358..23bdc24cf761ae7acf8ab5f5878eb7ae78761a6d 100644 (file)
@@ -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(
index 815ba0ebb2114fb223efb3894f115aa85f14d895..7971623021a32a9d5dbf4883a291334f4b9c3105 100644 (file)
@@ -23,6 +23,13 @@ bool Converter<base::DictionaryValue>::FromV8(v8::Isolate* isolate,
   }
 }
 
+v8::Handle<v8::Value> Converter<base::DictionaryValue>::ToV8(
+    v8::Isolate* isolate,
+    const base::DictionaryValue& val) {
+  scoped_ptr<atom::V8ValueConverter> converter(new atom::V8ValueConverter);
+  return converter->ToV8Value(&val, isolate->GetCurrentContext());
+}
+
 bool Converter<base::ListValue>::FromV8(v8::Isolate* isolate,
                                         v8::Local<v8::Value> val,
                                         base::ListValue* out) {
index bb0ef66e719bacfd2b880bb0738c525a81ec3f0f..27e00f4521df2d1577e59c665796c9d74d359be4 100644 (file)
@@ -19,6 +19,8 @@ struct Converter<base::DictionaryValue> {
   static bool FromV8(v8::Isolate* isolate,
                      v8::Local<v8::Value> val,
                      base::DictionaryValue* out);
+  static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
+                                    const base::DictionaryValue& val);
 };
 
 template<>
index cc68f2008b9e9de9536d9a54aef788fa66030de2..f7bc6396ecc7d61edc41d443d2f45f2c9585933f 100644 (file)
@@ -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'
 
index a1a472a5f1546edd2816da406df3e7ce365e3037..96484649ceb85822e325cbb323d890c418c6b90d 100644 (file)
@@ -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