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

Side by Side Diff: net/spdy/spdy_test_util.cc

Issue 3417010: Integrate the SpdyProxyClientSocket into the HttpStreamRequest... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Rebasing again Created 10 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« net/http/http_stream_request.cc ('K') | « net/spdy/spdy_test_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "net/spdy/spdy_test_util.h" 5 #include "net/spdy/spdy_test_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 extra_header_count, 400 extra_header_count,
401 compressed, 401 compressed,
402 stream_id, 402 stream_id,
403 request_priority, 403 request_priority,
404 spdy::SYN_STREAM, 404 spdy::SYN_STREAM,
405 spdy::CONTROL_FLAG_FIN, 405 spdy::CONTROL_FLAG_FIN,
406 kStandardGetHeaders, 406 kStandardGetHeaders,
407 arraysize(kStandardGetHeaders)); 407 arraysize(kStandardGetHeaders));
408 } 408 }
409 409
410 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request.
411 spdy::SpdyFrame* ConstructSpdyConnect(const char* const extra_headers[],
412 int extra_header_count,
413 int stream_id) {
414 const char* const kConnectHeaders[] = {
415 "method", "CONNECT",
416 "url", "www.google.com:443",
417 "host", "www.google.com",
418 "version", "HTTP/1.1",
419 "proxy-connection", "keep-alive",
420 };
421 return ConstructSpdyControlFrame(extra_headers,
422 extra_header_count,
423 /*compressed*/ false,
424 stream_id,
425 LOWEST,
426 spdy::SYN_STREAM,
427 spdy::CONTROL_FLAG_NONE,
428 kConnectHeaders,
429 arraysize(kConnectHeaders));
430 }
431
410 // Constructs a standard SPDY push SYN packet. 432 // Constructs a standard SPDY push SYN packet.
411 // |extra_headers| are the extra header-value pairs, which typically 433 // |extra_headers| are the extra header-value pairs, which typically
412 // will vary the most between calls. 434 // will vary the most between calls.
413 // Returns a SpdyFrame. 435 // Returns a SpdyFrame.
414 spdy::SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], 436 spdy::SpdyFrame* ConstructSpdyPush(const char* const extra_headers[],
415 int extra_header_count, 437 int extra_header_count,
416 int stream_id, 438 int stream_id,
417 int associated_stream_id) { 439 int associated_stream_id) {
418 const char* const kStandardGetHeaders[] = { 440 const char* const kStandardGetHeaders[] = {
419 "hello", 441 "hello",
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 0, 539 0,
518 false, 540 false,
519 stream_id, 541 stream_id,
520 LOWEST, 542 LOWEST,
521 spdy::SYN_REPLY, 543 spdy::SYN_REPLY,
522 spdy::CONTROL_FLAG_NONE, 544 spdy::CONTROL_FLAG_NONE,
523 kStandardGetHeaders, 545 kStandardGetHeaders,
524 arraysize(kStandardGetHeaders)); 546 arraysize(kStandardGetHeaders));
525 } 547 }
526 548
549 // Constructs a standard SPDY SYN_REPLY packet with an Internal Server
550 // Error status code.
551 // Returns a SpdyFrame.
552 spdy::SpdyFrame* ConstructSpdySynReplyError(int stream_id) {
553 return ConstructSpdySynReplyError("500 Internal Server Error", 1);
554 }
555
556 // Constructs a standard SPDY SYN_REPLY packet with the specified status code.
557 // Returns a SpdyFrame.
558 spdy::SpdyFrame* ConstructSpdySynReplyError(const char* const status,
559 int stream_id) {
560 static const char* const kStandardGetHeaders[] = {
561 "hello",
562 "bye",
563 "status",
564 status,
565 "version",
566 "HTTP/1.1"
567 };
568 return ConstructSpdyControlFrame(NULL,
569 0,
570 false,
571 stream_id,
572 LOWEST,
573 spdy::SYN_REPLY,
574 spdy::CONTROL_FLAG_NONE,
575 kStandardGetHeaders,
576 arraysize(kStandardGetHeaders));
577 }
578
527 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY GET. 579 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY GET.
528 // |extra_headers| are the extra header-value pairs, which typically 580 // |extra_headers| are the extra header-value pairs, which typically
529 // will vary the most between calls. 581 // will vary the most between calls.
530 // Returns a SpdyFrame. 582 // Returns a SpdyFrame.
531 spdy::SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[], 583 spdy::SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[],
532 int extra_header_count, 584 int extra_header_count,
533 int stream_id) { 585 int stream_id) {
534 static const char* const kStandardGetHeaders[] = { 586 static const char* const kStandardGetHeaders[] = {
535 "hello", 587 "hello",
536 "bye", 588 "bye",
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 } 674 }
623 675
624 // Constructs a single SPDY data frame with the given content. 676 // Constructs a single SPDY data frame with the given content.
625 spdy::SpdyFrame* ConstructSpdyBodyFrame(int stream_id, const char* data, 677 spdy::SpdyFrame* ConstructSpdyBodyFrame(int stream_id, const char* data,
626 uint32 len, bool fin) { 678 uint32 len, bool fin) {
627 spdy::SpdyFramer framer; 679 spdy::SpdyFramer framer;
628 return framer.CreateDataFrame( 680 return framer.CreateDataFrame(
629 stream_id, data, len, fin ? spdy::DATA_FLAG_FIN : spdy::DATA_FLAG_NONE); 681 stream_id, data, len, fin ? spdy::DATA_FLAG_FIN : spdy::DATA_FLAG_NONE);
630 } 682 }
631 683
684 // Wraps |frame| in the payload of a data frame in stream |stream_id|.
685 spdy::SpdyFrame* ConstructWrappedSpdyFrame(
686 const scoped_ptr<spdy::SpdyFrame>& frame,
687 int stream_id) {
688 return ConstructSpdyBodyFrame(stream_id, frame->data(),
689 frame->length() + spdy::SpdyFrame::size(),
690 false);
691 }
692
632 // Construct an expected SPDY reply string. 693 // Construct an expected SPDY reply string.
633 // |extra_headers| are the extra header-value pairs, which typically 694 // |extra_headers| are the extra header-value pairs, which typically
634 // will vary the most between calls. 695 // will vary the most between calls.
635 // |buffer| is the buffer we're filling in. 696 // |buffer| is the buffer we're filling in.
636 // Returns the number of bytes written into |buffer|. 697 // Returns the number of bytes written into |buffer|.
637 int ConstructSpdyReplyString(const char* const extra_headers[], 698 int ConstructSpdyReplyString(const char* const extra_headers[],
638 int extra_header_count, 699 int extra_header_count,
639 char* buffer, 700 char* buffer,
640 int buffer_length) { 701 int buffer_length) {
641 int packet_size = 0; 702 int packet_size = 0;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 spdy::CONTROL_FLAG_FIN, // Control Flags 829 spdy::CONTROL_FLAG_FIN, // Control Flags
769 false, // Compressed 830 false, // Compressed
770 spdy::INVALID, // Status 831 spdy::INVALID, // Status
771 NULL, // Data 832 NULL, // Data
772 0, // Length 833 0, // Length
773 spdy::DATA_FLAG_NONE // Data Flags 834 spdy::DATA_FLAG_NONE // Data Flags
774 }; 835 };
775 return kHeader; 836 return kHeader;
776 } 837 }
777 } // namespace net 838 } // namespace net
OLDNEW
« net/http/http_stream_request.cc ('K') | « net/spdy/spdy_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698