Merge pull request #1738 from deepak1556/http_ptach

webContents: providing header details with response event
This commit is contained in:
Cheng Zhao 2015-05-27 15:05:55 +08:00
commit 1c60575dc0
4 changed files with 21 additions and 6 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,13 +312,27 @@ void WebContents::DidStopLoading() {
void WebContents::DidGetResourceResponseStart(
const content::ResourceRequestDetails& details) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
mate::Dictionary response_headers(isolate, v8::Object::New(isolate));
net::HttpResponseHeaders* headers = details.response_info.headers.get();
void* iter = nullptr;
std::string key;
std::string value;
while (headers && headers->EnumerateHeaderLines(&iter, &key, &value))
response_headers.Set(base::StringToLowerASCII(key),
base::StringToLowerASCII(value));
Emit("did-get-response-details",
details.socket_address.IsEmpty(),
details.url,
details.original_url,
details.http_response_code,
details.method,
details.referrer);
details.referrer,
response_headers);
}
void WebContents::DidGetRedirectForResourceRequest(