OLD | NEW |
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_util.h" | 10 #include "base/string_util.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 if (!*this_value) | 241 if (!*this_value) |
242 this_value = ""; | 242 this_value = ""; |
243 int n = base::snprintf(buffer, | 243 int n = base::snprintf(buffer, |
244 buffer_length, | 244 buffer_length, |
245 "%s: %s\r\n", | 245 "%s: %s\r\n", |
246 this_header, | 246 this_header, |
247 this_value); | 247 this_value); |
248 return n; | 248 return n; |
249 } | 249 } |
250 | 250 |
| 251 // Constructs a standard SPDY GET SYN packet, optionally compressed |
| 252 // for the url |url|. |
| 253 // |extra_headers| are the extra header-value pairs, which typically |
| 254 // will vary the most between calls. |
| 255 // Returns a SpdyFrame. |
| 256 spdy::SpdyFrame* ConstructSpdyGet(const char* const url, |
| 257 bool compressed, |
| 258 int stream_id, |
| 259 RequestPriority request_priority) { |
| 260 const SpdyHeaderInfo kSynStartHeader = { |
| 261 spdy::SYN_STREAM, // Kind = Syn |
| 262 stream_id, // Stream ID |
| 263 0, // Associated stream ID |
| 264 request_priority, // Priority |
| 265 spdy::CONTROL_FLAG_FIN, // Control Flags |
| 266 compressed, // Compressed |
| 267 spdy::INVALID, // Status |
| 268 NULL, // Data |
| 269 0, // Length |
| 270 spdy::DATA_FLAG_NONE // Data Flags |
| 271 }; |
| 272 const char* const headers[] = { |
| 273 "method", |
| 274 "GET", |
| 275 "url", |
| 276 url, |
| 277 "version", |
| 278 "HTTP/1.1" |
| 279 }; |
| 280 return ConstructSpdyPacket( |
| 281 kSynStartHeader, |
| 282 NULL, |
| 283 0, |
| 284 headers, |
| 285 arraysize(headers) / 2); |
| 286 } |
| 287 |
251 // Constructs a standard SPDY GET SYN packet, optionally compressed. | 288 // Constructs a standard SPDY GET SYN packet, optionally compressed. |
252 // |extra_headers| are the extra header-value pairs, which typically | 289 // |extra_headers| are the extra header-value pairs, which typically |
253 // will vary the most between calls. | 290 // will vary the most between calls. |
254 // Returns a SpdyFrame. | 291 // Returns a SpdyFrame. |
255 spdy::SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], | 292 spdy::SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], |
256 int extra_header_count, | 293 int extra_header_count, |
257 bool compressed, | 294 bool compressed, |
258 int stream_id, | 295 int stream_id, |
259 RequestPriority request_priority) { | 296 RequestPriority request_priority) { |
260 const SpdyHeaderInfo kSynStartHeader = { | 297 const SpdyHeaderInfo kSynStartHeader = { |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 char* ptr = buff; | 551 char* ptr = buff; |
515 for (int i = 0; i < num_frames; ++i) { | 552 for (int i = 0; i < num_frames; ++i) { |
516 int len = frames[i]->length() + spdy::SpdyFrame::size(); | 553 int len = frames[i]->length() + spdy::SpdyFrame::size(); |
517 memcpy(ptr, frames[i]->data(), len); | 554 memcpy(ptr, frames[i]->data(), len); |
518 ptr += len; | 555 ptr += len; |
519 } | 556 } |
520 return total_len; | 557 return total_len; |
521 } | 558 } |
522 | 559 |
523 } // namespace net | 560 } // namespace net |
OLD | NEW |