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 <stdint.h> | 7 #include <stdint.h> |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 | 974 |
975 SpdyFrame* SpdyTestUtil::ConstructSpdyPush(const char* const extra_headers[], | 975 SpdyFrame* SpdyTestUtil::ConstructSpdyPush(const char* const extra_headers[], |
976 int extra_header_count, | 976 int extra_header_count, |
977 int stream_id, | 977 int stream_id, |
978 int associated_stream_id, | 978 int associated_stream_id, |
979 const char* url) { | 979 const char* url) { |
980 if (spdy_version() < HTTP2) { | 980 if (spdy_version() < HTTP2) { |
981 SpdySynStreamIR syn_stream(stream_id); | 981 SpdySynStreamIR syn_stream(stream_id); |
982 syn_stream.set_associated_to_stream_id(associated_stream_id); | 982 syn_stream.set_associated_to_stream_id(associated_stream_id); |
983 syn_stream.SetHeader("hello", "bye"); | 983 syn_stream.SetHeader("hello", "bye"); |
984 syn_stream.SetHeader(GetStatusKey(), "200 OK"); | 984 syn_stream.SetHeader(GetStatusKey(), "200"); |
985 syn_stream.SetHeader(GetVersionKey(), "HTTP/1.1"); | 985 syn_stream.SetHeader(GetVersionKey(), "HTTP/1.1"); |
986 AddUrlToHeaderBlock(url, syn_stream.mutable_header_block()); | 986 AddUrlToHeaderBlock(url, syn_stream.mutable_header_block()); |
987 AppendToHeaderBlock(extra_headers, extra_header_count, | 987 AppendToHeaderBlock(extra_headers, extra_header_count, |
988 syn_stream.mutable_header_block()); | 988 syn_stream.mutable_header_block()); |
989 return CreateFramer(false)->SerializeFrame(syn_stream); | 989 return CreateFramer(false)->SerializeFrame(syn_stream); |
990 } else { | 990 } else { |
991 SpdyPushPromiseIR push_promise(associated_stream_id, stream_id); | 991 SpdyPushPromiseIR push_promise(associated_stream_id, stream_id); |
992 AddUrlToHeaderBlock(url, push_promise.mutable_header_block()); | 992 AddUrlToHeaderBlock(url, push_promise.mutable_header_block()); |
993 scoped_ptr<SpdyFrame> push_promise_frame( | 993 scoped_ptr<SpdyFrame> push_promise_frame( |
994 CreateFramer(false)->SerializeFrame(push_promise)); | 994 CreateFramer(false)->SerializeFrame(push_promise)); |
995 | 995 |
996 SpdyHeadersIR headers(stream_id); | 996 SpdyHeadersIR headers(stream_id); |
997 headers.SetHeader(GetStatusKey(), "200 OK"); | 997 headers.SetHeader(GetStatusKey(), "200"); |
998 headers.SetHeader("hello", "bye"); | 998 headers.SetHeader("hello", "bye"); |
999 AppendToHeaderBlock(extra_headers, extra_header_count, | 999 AppendToHeaderBlock(extra_headers, extra_header_count, |
1000 headers.mutable_header_block()); | 1000 headers.mutable_header_block()); |
1001 scoped_ptr<SpdyFrame> headers_frame( | 1001 scoped_ptr<SpdyFrame> headers_frame( |
1002 CreateFramer(false)->SerializeFrame(headers)); | 1002 CreateFramer(false)->SerializeFrame(headers)); |
1003 | 1003 |
1004 int joint_data_size = push_promise_frame->size() + headers_frame->size(); | 1004 int joint_data_size = push_promise_frame->size() + headers_frame->size(); |
1005 scoped_ptr<char[]> data(new char[joint_data_size]); | 1005 scoped_ptr<char[]> data(new char[joint_data_size]); |
1006 const SpdyFrame* frames[2] = { | 1006 const SpdyFrame* frames[2] = { |
1007 push_promise_frame.get(), headers_frame.get(), | 1007 push_promise_frame.get(), headers_frame.get(), |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 push_promise.set_header_block(*headers); | 1073 push_promise.set_header_block(*headers); |
1074 return CreateFramer(false)->SerializeFrame(push_promise); | 1074 return CreateFramer(false)->SerializeFrame(push_promise); |
1075 } | 1075 } |
1076 } | 1076 } |
1077 | 1077 |
1078 SpdyFrame* SpdyTestUtil::ConstructSpdyPushHeaders( | 1078 SpdyFrame* SpdyTestUtil::ConstructSpdyPushHeaders( |
1079 int stream_id, | 1079 int stream_id, |
1080 const char* const extra_headers[], | 1080 const char* const extra_headers[], |
1081 int extra_header_count) { | 1081 int extra_header_count) { |
1082 SpdyHeadersIR headers(stream_id); | 1082 SpdyHeadersIR headers(stream_id); |
1083 headers.SetHeader(GetStatusKey(), "200 OK"); | 1083 headers.SetHeader(GetStatusKey(), "200"); |
1084 MaybeAddVersionHeader(&headers); | 1084 MaybeAddVersionHeader(&headers); |
1085 AppendToHeaderBlock(extra_headers, extra_header_count, | 1085 AppendToHeaderBlock(extra_headers, extra_header_count, |
1086 headers.mutable_header_block()); | 1086 headers.mutable_header_block()); |
1087 return CreateFramer(false)->SerializeFrame(headers); | 1087 return CreateFramer(false)->SerializeFrame(headers); |
1088 } | 1088 } |
1089 | 1089 |
1090 SpdyFrame* SpdyTestUtil::ConstructSpdyHeaderFrame(int stream_id, | 1090 SpdyFrame* SpdyTestUtil::ConstructSpdyHeaderFrame(int stream_id, |
1091 const char* const headers[], | 1091 const char* const headers[], |
1092 int header_count) { | 1092 int header_count) { |
1093 return ConstructSpdyHeaderFrame(stream_id, headers, header_count, false); | 1093 return ConstructSpdyHeaderFrame(stream_id, headers, header_count, false); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 } | 1344 } |
1345 } | 1345 } |
1346 | 1346 |
1347 void SpdyTestUtil::SetPriority(RequestPriority priority, | 1347 void SpdyTestUtil::SetPriority(RequestPriority priority, |
1348 SpdySynStreamIR* ir) const { | 1348 SpdySynStreamIR* ir) const { |
1349 ir->set_priority(ConvertRequestPriorityToSpdyPriority( | 1349 ir->set_priority(ConvertRequestPriorityToSpdyPriority( |
1350 priority, spdy_version())); | 1350 priority, spdy_version())); |
1351 } | 1351 } |
1352 | 1352 |
1353 } // namespace net | 1353 } // namespace net |
OLD | NEW |