OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_common.h" | 5 #include "net/spdy/spdy_test_util_common.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 GetPathKey(), path.c_str(), | 555 GetPathKey(), path.c_str(), |
556 GetHostKey(), host.c_str(), | 556 GetHostKey(), host.c_str(), |
557 GetSchemeKey(), scheme.c_str(), | 557 GetSchemeKey(), scheme.c_str(), |
558 GetVersionKey(), "HTTP/1.1" | 558 GetVersionKey(), "HTTP/1.1" |
559 }; | 559 }; |
560 scoped_ptr<SpdyHeaderBlock> header_block(new SpdyHeaderBlock()); | 560 scoped_ptr<SpdyHeaderBlock> header_block(new SpdyHeaderBlock()); |
561 AppendToHeaderBlock(headers, arraysize(headers) / 2, header_block.get()); | 561 AppendToHeaderBlock(headers, arraysize(headers) / 2, header_block.get()); |
562 return header_block.Pass(); | 562 return header_block.Pass(); |
563 } | 563 } |
564 | 564 |
| 565 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructGetHeaderBlockForProxy( |
| 566 base::StringPiece url) const { |
| 567 std::string scheme, host, path; |
| 568 ParseUrl(url.data(), &scheme, &host, &path); |
| 569 const char* const headers[] = { |
| 570 GetMethodKey(), "GET", |
| 571 GetPathKey(), is_spdy2() ? url.data() : path.c_str(), |
| 572 GetHostKey(), host.c_str(), |
| 573 GetSchemeKey(), scheme.c_str(), |
| 574 GetVersionKey(), "HTTP/1.1" |
| 575 }; |
| 576 scoped_ptr<SpdyHeaderBlock> header_block(new SpdyHeaderBlock()); |
| 577 AppendToHeaderBlock(headers, arraysize(headers) / 2, header_block.get()); |
| 578 return header_block.Pass(); |
| 579 } |
| 580 |
565 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructPostHeaderBlock( | 581 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructPostHeaderBlock( |
566 base::StringPiece url, | 582 base::StringPiece url, |
567 int64 content_length) const { | 583 int64 content_length) const { |
568 std::string scheme, host, path; | 584 std::string scheme, host, path; |
569 ParseUrl(url.data(), &scheme, &host, &path); | 585 ParseUrl(url.data(), &scheme, &host, &path); |
570 std::string length_str = base::Int64ToString(content_length); | 586 std::string length_str = base::Int64ToString(content_length); |
571 const char* const headers[] = { | 587 const char* const headers[] = { |
572 GetMethodKey(), "POST", | 588 GetMethodKey(), "POST", |
573 GetPathKey(), path.c_str(), | 589 GetPathKey(), path.c_str(), |
574 GetHostKey(), host.c_str(), | 590 GetHostKey(), host.c_str(), |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 | 1085 |
1070 const char* SpdyTestUtil::GetVersionKey() const { | 1086 const char* SpdyTestUtil::GetVersionKey() const { |
1071 return is_spdy2() ? "version" : ":version"; | 1087 return is_spdy2() ? "version" : ":version"; |
1072 } | 1088 } |
1073 | 1089 |
1074 const char* SpdyTestUtil::GetPathKey() const { | 1090 const char* SpdyTestUtil::GetPathKey() const { |
1075 return is_spdy2() ? "url" : ":path"; | 1091 return is_spdy2() ? "url" : ":path"; |
1076 } | 1092 } |
1077 | 1093 |
1078 } // namespace net | 1094 } // namespace net |
OLD | NEW |