Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(554)

Unified Diff: third_party/WebKit/Source/modules/fetch/Headers.cpp

Issue 2840193002: fetch: Align RequestInit's |headers| with the spec. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/fetch/Headers.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/Headers.cpp b/third_party/WebKit/Source/modules/fetch/Headers.cpp
index b8b6e61ab79bb9b484c61d15e1210ea3af77f9eb..d24a923dba09527f94d14c51bbdbf1d84a450dbe 100644
--- a/third_party/WebKit/Source/modules/fetch/Headers.cpp
+++ b/third_party/WebKit/Source/modules/fetch/Headers.cpp
@@ -59,16 +59,7 @@ Headers* Headers::Create(
// "1. Let |headers| be a new Headers object whose guard is "none".
Headers* headers = Create(exception_state);
// "2. If |init| is given, fill headers with |init|. Rethrow any exception."
- if (init.isByteStringSequenceSequence()) {
- headers->FillWith(init.getAsByteStringSequenceSequence(), exception_state);
- } else if (init.isByteStringByteStringRecord()) {
- headers->FillWith(init.getAsByteStringByteStringRecord(), exception_state);
- } else if (init.isHeaders()) {
- // This branch will not be necessary once http://crbug.com/690428 is fixed.
- headers->FillWith(init.getAsHeaders(), exception_state);
- } else {
- NOTREACHED();
- }
+ headers->FillWith(init, exception_state);
// "3. Return |headers|."
return headers;
}
@@ -243,6 +234,22 @@ void Headers::FillWith(const Headers* object, ExceptionState& exception_state) {
}
}
+void Headers::FillWith(
+ const ByteStringSequenceSequenceOrByteStringByteStringRecordOrHeaders& init,
+ ExceptionState& exception_state) {
+ DCHECK_EQ(header_list_->size(), 0U);
+ if (init.isByteStringSequenceSequence()) {
+ FillWith(init.getAsByteStringSequenceSequence(), exception_state);
+ } else if (init.isByteStringByteStringRecord()) {
+ FillWith(init.getAsByteStringByteStringRecord(), exception_state);
+ } else if (init.isHeaders()) {
+ // This branch will not be necessary once http://crbug.com/690428 is fixed.
+ FillWith(init.getAsHeaders(), exception_state);
+ } else {
+ NOTREACHED();
+ }
+}
+
void Headers::FillWith(const Vector<Vector<String>>& object,
ExceptionState& exception_state) {
DCHECK(!header_list_->size());

Powered by Google App Engine
This is Rietveld 408576698