OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 #include <iostream> | 6 #include <iostream> |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 DISALLOW_COPY_AND_ASSIGN(DecompressionVisitor); | 215 DISALLOW_COPY_AND_ASSIGN(DecompressionVisitor); |
216 }; | 216 }; |
217 | 217 |
218 private: | 218 private: |
219 DISALLOW_COPY_AND_ASSIGN(SpdyFramerTestUtil); | 219 DISALLOW_COPY_AND_ASSIGN(SpdyFramerTestUtil); |
220 }; | 220 }; |
221 | 221 |
222 class TestSpdyVisitor : public SpdyFramerVisitorInterface, | 222 class TestSpdyVisitor : public SpdyFramerVisitorInterface, |
223 public SpdyFramerDebugVisitorInterface { | 223 public SpdyFramerDebugVisitorInterface { |
224 public: | 224 public: |
| 225 // This is larger than our max frame size because header blocks that |
| 226 // are too long can spill over into CONTINUATION frames. |
225 static const size_t kDefaultHeaderBufferSize = 16 * 1024 * 1024; | 227 static const size_t kDefaultHeaderBufferSize = 16 * 1024 * 1024; |
226 | 228 |
227 explicit TestSpdyVisitor(SpdyMajorVersion version) | 229 explicit TestSpdyVisitor(SpdyMajorVersion version) |
228 : framer_(version), | 230 : framer_(version), |
229 use_compression_(false), | 231 use_compression_(false), |
230 error_count_(0), | 232 error_count_(0), |
231 syn_frame_count_(0), | 233 syn_frame_count_(0), |
232 syn_reply_frame_count_(0), | 234 syn_reply_frame_count_(0), |
233 headers_frame_count_(0), | 235 headers_frame_count_(0), |
| 236 push_promise_frame_count_(0), |
234 goaway_count_(0), | 237 goaway_count_(0), |
235 setting_count_(0), | 238 setting_count_(0), |
236 settings_ack_sent_(0), | 239 settings_ack_sent_(0), |
237 settings_ack_received_(0), | 240 settings_ack_received_(0), |
238 continuation_count_(0), | 241 continuation_count_(0), |
239 last_window_update_stream_(0), | 242 last_window_update_stream_(0), |
240 last_window_update_delta_(0), | 243 last_window_update_delta_(0), |
241 last_push_promise_stream_(0), | 244 last_push_promise_stream_(0), |
242 last_push_promise_promised_stream_(0), | 245 last_push_promise_promised_stream_(0), |
243 data_bytes_(0), | 246 data_bytes_(0), |
(...skipping 10 matching lines...) Expand all Loading... |
254 header_buffer_length_(0), | 257 header_buffer_length_(0), |
255 header_buffer_size_(kDefaultHeaderBufferSize), | 258 header_buffer_size_(kDefaultHeaderBufferSize), |
256 header_stream_id_(-1), | 259 header_stream_id_(-1), |
257 header_control_type_(DATA), | 260 header_control_type_(DATA), |
258 header_buffer_valid_(false) { | 261 header_buffer_valid_(false) { |
259 } | 262 } |
260 | 263 |
261 virtual void OnError(SpdyFramer* f) OVERRIDE { | 264 virtual void OnError(SpdyFramer* f) OVERRIDE { |
262 LOG(INFO) << "SpdyFramer Error: " | 265 LOG(INFO) << "SpdyFramer Error: " |
263 << SpdyFramer::ErrorCodeToString(f->error_code()); | 266 << SpdyFramer::ErrorCodeToString(f->error_code()); |
264 error_count_++; | 267 ++error_count_; |
265 } | 268 } |
266 | 269 |
267 virtual void OnDataFrameHeader(SpdyStreamId stream_id, | 270 virtual void OnDataFrameHeader(SpdyStreamId stream_id, |
268 size_t length, | 271 size_t length, |
269 bool fin) OVERRIDE { | 272 bool fin) OVERRIDE { |
270 data_frame_count_++; | 273 ++data_frame_count_; |
271 header_stream_id_ = stream_id; | 274 header_stream_id_ = stream_id; |
272 } | 275 } |
273 | 276 |
274 virtual void OnStreamFrameData(SpdyStreamId stream_id, | 277 virtual void OnStreamFrameData(SpdyStreamId stream_id, |
275 const char* data, | 278 const char* data, |
276 size_t len, | 279 size_t len, |
277 bool fin) OVERRIDE { | 280 bool fin) OVERRIDE { |
278 EXPECT_EQ(header_stream_id_, stream_id); | 281 EXPECT_EQ(header_stream_id_, stream_id); |
279 if (len == 0) | 282 if (len == 0) |
280 ++zero_length_data_frame_count_; | 283 ++zero_length_data_frame_count_; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 memcpy(header_buffer_.get() + header_buffer_length_, header_data, len); | 317 memcpy(header_buffer_.get() + header_buffer_length_, header_data, len); |
315 header_buffer_length_ += len; | 318 header_buffer_length_ += len; |
316 return true; | 319 return true; |
317 } | 320 } |
318 | 321 |
319 virtual void OnSynStream(SpdyStreamId stream_id, | 322 virtual void OnSynStream(SpdyStreamId stream_id, |
320 SpdyStreamId associated_stream_id, | 323 SpdyStreamId associated_stream_id, |
321 SpdyPriority priority, | 324 SpdyPriority priority, |
322 bool fin, | 325 bool fin, |
323 bool unidirectional) OVERRIDE { | 326 bool unidirectional) OVERRIDE { |
324 syn_frame_count_++; | 327 ++syn_frame_count_; |
325 InitHeaderStreaming(SYN_STREAM, stream_id); | 328 InitHeaderStreaming(SYN_STREAM, stream_id); |
326 if (fin) { | 329 if (fin) { |
327 fin_flag_count_++; | 330 ++fin_flag_count_; |
328 } | 331 } |
329 } | 332 } |
330 | 333 |
331 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) OVERRIDE { | 334 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) OVERRIDE { |
332 syn_reply_frame_count_++; | 335 ++syn_reply_frame_count_; |
333 InitHeaderStreaming(SYN_REPLY, stream_id); | 336 InitHeaderStreaming(SYN_REPLY, stream_id); |
334 if (fin) { | 337 if (fin) { |
335 fin_flag_count_++; | 338 ++fin_flag_count_; |
336 } | 339 } |
337 } | 340 } |
338 | 341 |
339 virtual void OnRstStream(SpdyStreamId stream_id, | 342 virtual void OnRstStream(SpdyStreamId stream_id, |
340 SpdyRstStreamStatus status) OVERRIDE { | 343 SpdyRstStreamStatus status) OVERRIDE { |
341 fin_frame_count_++; | 344 ++fin_frame_count_; |
342 } | 345 } |
343 | 346 |
344 virtual bool OnRstStreamFrameData(const char* rst_stream_data, | 347 virtual bool OnRstStreamFrameData(const char* rst_stream_data, |
345 size_t len) OVERRIDE { | 348 size_t len) OVERRIDE { |
346 if ((rst_stream_data != NULL) && (len > 0)) { | 349 if ((rst_stream_data != NULL) && (len > 0)) { |
347 fin_opaque_data_ += std::string(rst_stream_data, len); | 350 fin_opaque_data_ += std::string(rst_stream_data, len); |
348 } | 351 } |
349 return true; | 352 return true; |
350 } | 353 } |
351 | 354 |
352 virtual void OnSetting(SpdySettingsIds id, | 355 virtual void OnSetting(SpdySettingsIds id, |
353 uint8 flags, | 356 uint8 flags, |
354 uint32 value) OVERRIDE { | 357 uint32 value) OVERRIDE { |
355 setting_count_++; | 358 ++setting_count_; |
356 } | 359 } |
357 | 360 |
358 virtual void OnSettingsAck() OVERRIDE { | 361 virtual void OnSettingsAck() OVERRIDE { |
359 DCHECK_GE(4, framer_.protocol_version()); | 362 DCHECK_GE(4, framer_.protocol_version()); |
360 settings_ack_received_++; | 363 ++settings_ack_received_; |
361 } | 364 } |
362 | 365 |
363 virtual void OnSettingsEnd() OVERRIDE { | 366 virtual void OnSettingsEnd() OVERRIDE { |
364 if (framer_.protocol_version() < 4) { return; } | 367 if (framer_.protocol_version() < 4) { return; } |
365 settings_ack_sent_++; | 368 ++settings_ack_sent_; |
366 } | 369 } |
367 | 370 |
368 virtual void OnPing(SpdyPingId unique_id, bool is_ack) OVERRIDE { | 371 virtual void OnPing(SpdyPingId unique_id, bool is_ack) OVERRIDE { |
369 DLOG(FATAL); | 372 DLOG(FATAL); |
370 } | 373 } |
371 | 374 |
372 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id, | 375 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id, |
373 SpdyGoAwayStatus status) OVERRIDE { | 376 SpdyGoAwayStatus status) OVERRIDE { |
374 goaway_count_++; | 377 ++goaway_count_; |
375 } | 378 } |
376 | 379 |
377 virtual void OnHeaders(SpdyStreamId stream_id, bool fin, bool end) OVERRIDE { | 380 virtual void OnHeaders(SpdyStreamId stream_id, bool fin, bool end) OVERRIDE { |
378 headers_frame_count_++; | 381 ++headers_frame_count_; |
379 InitHeaderStreaming(HEADERS, stream_id); | 382 InitHeaderStreaming(HEADERS, stream_id); |
380 if (fin) { | 383 if (fin) { |
381 fin_flag_count_++; | 384 ++fin_flag_count_; |
382 } | 385 } |
383 } | 386 } |
384 | 387 |
385 virtual void OnWindowUpdate(SpdyStreamId stream_id, | 388 virtual void OnWindowUpdate(SpdyStreamId stream_id, |
386 uint32 delta_window_size) OVERRIDE { | 389 uint32 delta_window_size) OVERRIDE { |
387 last_window_update_stream_ = stream_id; | 390 last_window_update_stream_ = stream_id; |
388 last_window_update_delta_ = delta_window_size; | 391 last_window_update_delta_ = delta_window_size; |
389 } | 392 } |
390 | 393 |
391 virtual void OnPushPromise(SpdyStreamId stream_id, | 394 virtual void OnPushPromise(SpdyStreamId stream_id, |
392 SpdyStreamId promised_stream_id, | 395 SpdyStreamId promised_stream_id, |
393 bool end) OVERRIDE { | 396 bool end) OVERRIDE { |
| 397 ++push_promise_frame_count_; |
394 InitHeaderStreaming(PUSH_PROMISE, stream_id); | 398 InitHeaderStreaming(PUSH_PROMISE, stream_id); |
395 last_push_promise_stream_ = stream_id; | 399 last_push_promise_stream_ = stream_id; |
396 last_push_promise_promised_stream_ = promised_stream_id; | 400 last_push_promise_promised_stream_ = promised_stream_id; |
397 } | 401 } |
398 | 402 |
399 virtual void OnContinuation(SpdyStreamId stream_id, bool end) OVERRIDE { | 403 virtual void OnContinuation(SpdyStreamId stream_id, bool end) OVERRIDE { |
400 continuation_count_++; | 404 ++continuation_count_; |
401 } | 405 } |
402 | 406 |
403 virtual void OnSendCompressedFrame(SpdyStreamId stream_id, | 407 virtual void OnSendCompressedFrame(SpdyStreamId stream_id, |
404 SpdyFrameType type, | 408 SpdyFrameType type, |
405 size_t payload_len, | 409 size_t payload_len, |
406 size_t frame_len) OVERRIDE { | 410 size_t frame_len) OVERRIDE { |
407 last_payload_len_ = payload_len; | 411 last_payload_len_ = payload_len; |
408 last_frame_len_ = frame_len; | 412 last_frame_len_ = frame_len; |
409 } | 413 } |
410 | 414 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 } | 461 } |
458 | 462 |
459 SpdyFramer framer_; | 463 SpdyFramer framer_; |
460 bool use_compression_; | 464 bool use_compression_; |
461 | 465 |
462 // Counters from the visitor callbacks. | 466 // Counters from the visitor callbacks. |
463 int error_count_; | 467 int error_count_; |
464 int syn_frame_count_; | 468 int syn_frame_count_; |
465 int syn_reply_frame_count_; | 469 int syn_reply_frame_count_; |
466 int headers_frame_count_; | 470 int headers_frame_count_; |
| 471 int push_promise_frame_count_; |
467 int goaway_count_; | 472 int goaway_count_; |
468 int setting_count_; | 473 int setting_count_; |
469 int settings_ack_sent_; | 474 int settings_ack_sent_; |
470 int settings_ack_received_; | 475 int settings_ack_received_; |
471 int continuation_count_; | 476 int continuation_count_; |
472 SpdyStreamId last_window_update_stream_; | 477 SpdyStreamId last_window_update_stream_; |
473 uint32 last_window_update_delta_; | 478 uint32 last_window_update_delta_; |
474 SpdyStreamId last_push_promise_stream_; | 479 SpdyStreamId last_push_promise_stream_; |
475 SpdyStreamId last_push_promise_promised_stream_; | 480 SpdyStreamId last_push_promise_promised_stream_; |
476 int data_bytes_; | 481 int data_bytes_; |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 | 757 |
753 TEST_P(SpdyFramerTest, DuplicateHeader) { | 758 TEST_P(SpdyFramerTest, DuplicateHeader) { |
754 if (spdy_version_ >= 4) { | 759 if (spdy_version_ >= 4) { |
755 // TODO(jgraettinger): Punting on this because we haven't determined | 760 // TODO(jgraettinger): Punting on this because we haven't determined |
756 // whether duplicate HPACK headers other than Cookie are an error. | 761 // whether duplicate HPACK headers other than Cookie are an error. |
757 // If they are, this will need to be updated to use HpackOutputStream. | 762 // If they are, this will need to be updated to use HpackOutputStream. |
758 return; | 763 return; |
759 } | 764 } |
760 SpdyFramer framer(spdy_version_); | 765 SpdyFramer framer(spdy_version_); |
761 // Frame builder with plentiful buffer size. | 766 // Frame builder with plentiful buffer size. |
762 SpdyFrameBuilder frame(1024); | 767 SpdyFrameBuilder frame(1024, spdy_version_); |
763 if (spdy_version_ < 4) { | 768 if (spdy_version_ < 4) { |
764 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE); | 769 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE); |
765 frame.WriteUInt32(3); // stream_id | 770 frame.WriteUInt32(3); // stream_id |
766 frame.WriteUInt32(0); // associated stream id | 771 frame.WriteUInt32(0); // associated stream id |
767 frame.WriteUInt16(0); // Priority. | 772 frame.WriteUInt16(0); // Priority. |
768 } else { | 773 } else { |
769 frame.WriteFramePrefix(framer, HEADERS, HEADERS_FLAG_PRIORITY, 3); | 774 frame.BeginNewFrame(framer, HEADERS, HEADERS_FLAG_PRIORITY, 3); |
770 frame.WriteUInt32(framer.GetHighestPriority()); | 775 frame.WriteUInt32(framer.GetHighestPriority()); |
771 } | 776 } |
772 | 777 |
773 if (IsSpdy2()) { | 778 if (IsSpdy2()) { |
774 frame.WriteUInt16(2); // Number of headers. | 779 frame.WriteUInt16(2); // Number of headers. |
775 frame.WriteString("name"); | 780 frame.WriteString("name"); |
776 frame.WriteString("value1"); | 781 frame.WriteString("value1"); |
777 frame.WriteString("name"); | 782 frame.WriteString("name"); |
778 frame.WriteString("value2"); | 783 frame.WriteString("value2"); |
779 } else { | 784 } else { |
(...skipping 13 matching lines...) Expand all Loading... |
793 GetSerializedHeaders(control_frame.get(), framer); | 798 GetSerializedHeaders(control_frame.get(), framer); |
794 // This should fail because duplicate headers are verboten by the spec. | 799 // This should fail because duplicate headers are verboten by the spec. |
795 EXPECT_FALSE(framer.ParseHeaderBlockInBuffer(serialized_headers.data(), | 800 EXPECT_FALSE(framer.ParseHeaderBlockInBuffer(serialized_headers.data(), |
796 serialized_headers.size(), | 801 serialized_headers.size(), |
797 &new_headers)); | 802 &new_headers)); |
798 } | 803 } |
799 | 804 |
800 TEST_P(SpdyFramerTest, MultiValueHeader) { | 805 TEST_P(SpdyFramerTest, MultiValueHeader) { |
801 SpdyFramer framer(spdy_version_); | 806 SpdyFramer framer(spdy_version_); |
802 // Frame builder with plentiful buffer size. | 807 // Frame builder with plentiful buffer size. |
803 SpdyFrameBuilder frame(1024); | 808 SpdyFrameBuilder frame(1024, spdy_version_); |
804 if (spdy_version_ < 4) { | 809 if (spdy_version_ < 4) { |
805 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE); | 810 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE); |
806 frame.WriteUInt32(3); // stream_id | 811 frame.WriteUInt32(3); // stream_id |
807 frame.WriteUInt32(0); // associated stream id | 812 frame.WriteUInt32(0); // associated stream id |
808 frame.WriteUInt16(0); // Priority. | 813 frame.WriteUInt16(0); // Priority. |
809 } else { | 814 } else { |
810 frame.WriteFramePrefix(framer, | 815 frame.BeginNewFrame(framer, |
811 HEADERS, | 816 HEADERS, |
812 HEADERS_FLAG_PRIORITY | HEADERS_FLAG_END_HEADERS, | 817 HEADERS_FLAG_PRIORITY | HEADERS_FLAG_END_HEADERS, |
813 3); | 818 3); |
814 frame.WriteUInt32(framer.GetHighestPriority()); | 819 frame.WriteUInt32(framer.GetHighestPriority()); |
815 } | 820 } |
816 | 821 |
817 string value("value1\0value2", 13); | 822 string value("value1\0value2", 13); |
818 if (IsSpdy2()) { | 823 if (IsSpdy2()) { |
819 frame.WriteUInt16(1); // Number of headers. | 824 frame.WriteUInt16(1); // Number of headers. |
820 frame.WriteString("name"); | 825 frame.WriteString("name"); |
821 frame.WriteString(value); | 826 frame.WriteString(value); |
822 } else if (spdy_version_ >= 4) { | 827 } else if (spdy_version_ >= 4) { |
823 HpackOutputStream output_stream(1024); | 828 HpackOutputStream output_stream(1024); |
(...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3056 control_frame->size()); | 3061 control_frame->size()); |
3057 EXPECT_FALSE(visitor.header_buffer_valid_); | 3062 EXPECT_FALSE(visitor.header_buffer_valid_); |
3058 EXPECT_EQ(1, visitor.error_count_); | 3063 EXPECT_EQ(1, visitor.error_count_); |
3059 EXPECT_EQ(SpdyFramer::SPDY_CONTROL_PAYLOAD_TOO_LARGE, | 3064 EXPECT_EQ(SpdyFramer::SPDY_CONTROL_PAYLOAD_TOO_LARGE, |
3060 visitor.framer_.error_code()) | 3065 visitor.framer_.error_code()) |
3061 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 3066 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
3062 EXPECT_EQ(0, visitor.syn_frame_count_); | 3067 EXPECT_EQ(0, visitor.syn_frame_count_); |
3063 EXPECT_EQ(0u, visitor.header_buffer_length_); | 3068 EXPECT_EQ(0u, visitor.header_buffer_length_); |
3064 } | 3069 } |
3065 | 3070 |
| 3071 TEST_P(SpdyFramerTest, TooLargeHeadersFrameUsesContinuation) { |
| 3072 if (spdy_version_ < net::SPDY4) { |
| 3073 return; |
| 3074 } |
| 3075 SpdyFramer framer(spdy_version_); |
| 3076 framer.set_enable_compression(false); |
| 3077 SpdyHeadersIR headers(1); |
| 3078 |
| 3079 // Exact payload length will change with HPACK, but this should be long |
| 3080 // enough to cause an overflow. |
| 3081 const size_t kBigValueSize = framer.GetControlFrameBufferMaxSize(); |
| 3082 string big_value(kBigValueSize, 'x'); |
| 3083 headers.SetHeader("aa", big_value.c_str()); |
| 3084 scoped_ptr<SpdyFrame> control_frame(framer.SerializeHeaders(headers)); |
| 3085 EXPECT_TRUE(control_frame.get() != NULL); |
| 3086 EXPECT_GT(control_frame->size(), framer.GetControlFrameBufferMaxSize()); |
| 3087 |
| 3088 TestSpdyVisitor visitor(spdy_version_); |
| 3089 visitor.SimulateInFramer( |
| 3090 reinterpret_cast<unsigned char*>(control_frame->data()), |
| 3091 control_frame->size()); |
| 3092 EXPECT_TRUE(visitor.header_buffer_valid_); |
| 3093 EXPECT_EQ(0, visitor.error_count_); |
| 3094 EXPECT_EQ(1, visitor.headers_frame_count_); |
| 3095 EXPECT_EQ(1, visitor.continuation_count_); |
| 3096 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); |
| 3097 } |
| 3098 |
| 3099 TEST_P(SpdyFramerTest, TooLargePushPromiseFrameUsesContinuation) { |
| 3100 if (spdy_version_ < net::SPDY4) { |
| 3101 return; |
| 3102 } |
| 3103 SpdyFramer framer(spdy_version_); |
| 3104 framer.set_enable_compression(false); |
| 3105 SpdyPushPromiseIR push_promise(1, 2); |
| 3106 |
| 3107 // Exact payload length will change with HPACK, but this should be long |
| 3108 // enough to cause an overflow. |
| 3109 const size_t kBigValueSize = framer.GetControlFrameBufferMaxSize(); |
| 3110 string big_value(kBigValueSize, 'x'); |
| 3111 push_promise.SetHeader("aa", big_value.c_str()); |
| 3112 scoped_ptr<SpdyFrame> control_frame( |
| 3113 framer.SerializePushPromise(push_promise)); |
| 3114 EXPECT_TRUE(control_frame.get() != NULL); |
| 3115 EXPECT_GT(control_frame->size(), framer.GetControlFrameBufferMaxSize()); |
| 3116 |
| 3117 TestSpdyVisitor visitor(spdy_version_); |
| 3118 visitor.SimulateInFramer( |
| 3119 reinterpret_cast<unsigned char*>(control_frame->data()), |
| 3120 control_frame->size()); |
| 3121 EXPECT_TRUE(visitor.header_buffer_valid_); |
| 3122 EXPECT_EQ(0, visitor.error_count_); |
| 3123 EXPECT_EQ(1, visitor.push_promise_frame_count_); |
| 3124 EXPECT_EQ(1, visitor.continuation_count_); |
| 3125 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); |
| 3126 } |
| 3127 |
3066 // Check that the framer stops delivering header data chunks once the visitor | 3128 // Check that the framer stops delivering header data chunks once the visitor |
3067 // declares it doesn't want any more. This is important to guard against | 3129 // declares it doesn't want any more. This is important to guard against |
3068 // "zip bomb" types of attacks. | 3130 // "zip bomb" types of attacks. |
3069 TEST_P(SpdyFramerTest, ControlFrameMuchTooLarge) { | 3131 TEST_P(SpdyFramerTest, ControlFrameMuchTooLarge) { |
3070 const size_t kHeaderBufferChunks = 4; | 3132 const size_t kHeaderBufferChunks = 4; |
3071 const size_t kHeaderBufferSize = | 3133 const size_t kHeaderBufferSize = |
3072 TestSpdyVisitor::header_data_chunk_max_size() * kHeaderBufferChunks; | 3134 TestSpdyVisitor::header_data_chunk_max_size() * kHeaderBufferChunks; |
3073 const size_t kBigValueSize = kHeaderBufferSize * 2; | 3135 const size_t kBigValueSize = kHeaderBufferSize * 2; |
3074 string big_value(kBigValueSize, 'x'); | 3136 string big_value(kBigValueSize, 'x'); |
3075 SpdyFramer framer(spdy_version_); | 3137 SpdyFramer framer(spdy_version_); |
(...skipping 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4836 SpdyBlockedIR blocked_ir(0); | 4898 SpdyBlockedIR blocked_ir(0); |
4837 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); | 4899 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); |
4838 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); | 4900 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); |
4839 | 4901 |
4840 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 4902 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
4841 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) | 4903 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) |
4842 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 4904 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
4843 } | 4905 } |
4844 | 4906 |
4845 } // namespace net | 4907 } // namespace net |
OLD | NEW |