fix: properly handle optional requestHeaders with onBeforeSendHeaders (#29798)

This commit is contained in:
David Sanders 2021-06-21 23:08:52 -07:00 committed by GitHub
parent 0ad73ac423
commit bc8cb75e4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View file

@ -214,8 +214,11 @@ void ReadFromResponse(v8::Isolate* isolate,
void ReadFromResponse(v8::Isolate* isolate,
gin::Dictionary* response,
net::HttpRequestHeaders* headers) {
headers->Clear();
response->Get("requestHeaders", headers);
v8::Local<v8::Value> value;
if (response->Get("requestHeaders", &value) && value->IsObject()) {
headers->Clear();
gin::Converter<net::HttpRequestHeaders>::FromV8(isolate, value, headers);
}
}
void ReadFromResponse(v8::Isolate* isolate,