OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/fetch/Headers.h" | 5 #include "modules/fetch/Headers.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/V8IteratorResultValue.h" | 8 #include "bindings/core/v8/V8IteratorResultValue.h" |
9 #include "bindings/modules/v8/ByteStringSequenceSequenceOrByteStringByteStringRe
cordOrHeaders.h" | 9 #include "bindings/modules/v8/ByteStringSequenceSequenceOrByteStringByteStringRe
cordOrHeaders.h" |
10 #include "core/dom/Iterator.h" | 10 #include "core/dom/Iterator.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 return String(); | 160 return String(); |
161 } | 161 } |
162 // "2. If there is no header in header list whose name is |name|, | 162 // "2. If there is no header in header list whose name is |name|, |
163 // return null." | 163 // return null." |
164 // "3. Return the combined value given |name| and header list." | 164 // "3. Return the combined value given |name| and header list." |
165 String result; | 165 String result; |
166 header_list_->Get(name, result); | 166 header_list_->Get(name, result); |
167 return result; | 167 return result; |
168 } | 168 } |
169 | 169 |
170 Vector<String> Headers::getAll(const String& name, | |
171 ExceptionState& exception_state) { | |
172 // "The getAll(|name|) method, when invoked, must run these steps:" | |
173 // "1. If |name| is not a name, throw a TypeError." | |
174 if (!FetchHeaderList::IsValidHeaderName(name)) { | |
175 exception_state.ThrowTypeError("Invalid name"); | |
176 return Vector<String>(); | |
177 } | |
178 // "2. Return the values of all headers in header list whose name is |name|, | |
179 // in list order, and the empty sequence otherwise." | |
180 Vector<String> result; | |
181 header_list_->GetAll(name, result); | |
182 return result; | |
183 } | |
184 | |
185 bool Headers::has(const String& name, ExceptionState& exception_state) { | 170 bool Headers::has(const String& name, ExceptionState& exception_state) { |
186 // "The has(|name|) method, when invoked, must run these steps:" | 171 // "The has(|name|) method, when invoked, must run these steps:" |
187 // "1. If |name| is not a name, throw a TypeError." | 172 // "1. If |name| is not a name, throw a TypeError." |
188 if (!FetchHeaderList::IsValidHeaderName(name)) { | 173 if (!FetchHeaderList::IsValidHeaderName(name)) { |
189 exception_state.ThrowTypeError("Invalid name"); | 174 exception_state.ThrowTypeError("Invalid name"); |
190 return false; | 175 return false; |
191 } | 176 } |
192 // "2. Return true if there is a header in header list whose name is |name|, | 177 // "2. Return true if there is a header in header list whose name is |name|, |
193 // and false otherwise." | 178 // and false otherwise." |
194 return header_list_->Has(name); | 179 return header_list_->Has(name); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 visitor->Trace(header_list_); | 269 visitor->Trace(header_list_); |
285 } | 270 } |
286 | 271 |
287 PairIterable<String, String>::IterationSource* Headers::StartIteration( | 272 PairIterable<String, String>::IterationSource* Headers::StartIteration( |
288 ScriptState*, | 273 ScriptState*, |
289 ExceptionState&) { | 274 ExceptionState&) { |
290 return new HeadersIterationSource(header_list_); | 275 return new HeadersIterationSource(header_list_); |
291 } | 276 } |
292 | 277 |
293 } // namespace blink | 278 } // namespace blink |
OLD | NEW |