Merge pull request #1873 from atom/multiline-headers
Support multiple-line headers in `did-get-response-details'
This commit is contained in:
commit
89087d402d
3 changed files with 26 additions and 5 deletions
|
@ -287,15 +287,27 @@ void WebContents::DidGetResourceResponseStart(
|
|||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::Locker locker(isolate);
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
mate::Dictionary response_headers(isolate, v8::Object::New(isolate));
|
||||
base::DictionaryValue response_headers;
|
||||
|
||||
net::HttpResponseHeaders* headers = details.headers.get();
|
||||
if (!headers)
|
||||
return;
|
||||
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));
|
||||
while (headers->EnumerateHeaderLines(&iter, &key, &value)) {
|
||||
key = base::StringToLowerASCII(key);
|
||||
value = base::StringToLowerASCII(value);
|
||||
if (response_headers.HasKey(key)) {
|
||||
base::ListValue* values = nullptr;
|
||||
if (response_headers.GetList(key, &values))
|
||||
values->AppendString(value);
|
||||
} else {
|
||||
scoped_ptr<base::ListValue> values(new base::ListValue());
|
||||
values->AppendString(value);
|
||||
response_headers.Set(key, values.Pass());
|
||||
}
|
||||
}
|
||||
|
||||
Emit("did-get-response-details",
|
||||
details.socket_address.IsEmpty(),
|
||||
|
|
|
@ -23,6 +23,13 @@ bool Converter<base::DictionaryValue>::FromV8(v8::Isolate* isolate,
|
|||
}
|
||||
}
|
||||
|
||||
v8::Local<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) {
|
||||
|
|
|
@ -19,6 +19,8 @@ struct Converter<base::DictionaryValue> {
|
|||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
base::DictionaryValue* out);
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const base::DictionaryValue& val);
|
||||
};
|
||||
|
||||
template<>
|
||||
|
@ -27,7 +29,7 @@ struct Converter<base::ListValue> {
|
|||
v8::Local<v8::Value> val,
|
||||
base::ListValue* out);
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const base::ListValue& val);
|
||||
const base::ListValue& val);
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
|
Loading…
Reference in a new issue