return headers as object

This commit is contained in:
deepak1556 2015-05-22 02:52:52 +05:30
parent c22b138b67
commit 4d5790dc09
5 changed files with 23 additions and 5 deletions

View 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(

View 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) {

View 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<>

View 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'

View 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