| 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 #ifndef NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 5 #ifndef NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
| 6 #define NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 6 #define NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 // Construct a SPDY WINDOW_UPDATE frame. | 330 // Construct a SPDY WINDOW_UPDATE frame. |
| 331 // Returns the constructed frame. The caller takes ownership of the frame. | 331 // Returns the constructed frame. The caller takes ownership of the frame. |
| 332 SpdySerializedFrame ConstructSpdyWindowUpdate(SpdyStreamId stream_id, | 332 SpdySerializedFrame ConstructSpdyWindowUpdate(SpdyStreamId stream_id, |
| 333 uint32_t delta_window_size); | 333 uint32_t delta_window_size); |
| 334 | 334 |
| 335 // Construct a SPDY RST_STREAM frame. | 335 // Construct a SPDY RST_STREAM frame. |
| 336 // Returns the constructed frame. The caller takes ownership of the frame. | 336 // Returns the constructed frame. The caller takes ownership of the frame. |
| 337 SpdySerializedFrame ConstructSpdyRstStream(SpdyStreamId stream_id, | 337 SpdySerializedFrame ConstructSpdyRstStream(SpdyStreamId stream_id, |
| 338 SpdyRstStreamStatus status); | 338 SpdyRstStreamStatus status); |
| 339 | 339 |
| 340 // Constructs a standard SPDY GET SYN frame for |url| with header compression. | 340 // Constructs a standard SPDY GET HEADERS frame for |url| with header |
| 341 // compression. |
| 341 // |extra_headers| are the extra header-value pairs, which typically | 342 // |extra_headers| are the extra header-value pairs, which typically |
| 342 // will vary the most between calls. | 343 // will vary the most between calls. |
| 343 // Returns a SpdySerializedFrame. | 344 // Returns a SpdySerializedFrame. |
| 344 SpdySerializedFrame ConstructSpdyGet(const char* const url, | 345 SpdySerializedFrame ConstructSpdyGet(const char* const url, |
| 345 SpdyStreamId stream_id, | 346 SpdyStreamId stream_id, |
| 346 RequestPriority request_priority); | 347 RequestPriority request_priority); |
| 347 | 348 |
| 348 // Constructs a standard SPDY GET SYN frame with header compression. | 349 // Constructs a standard SPDY GET HEADERS frame with header compression. |
| 349 // |extra_headers| are the extra header-value pairs, which typically | 350 // |extra_headers| are the extra header-value pairs, which typically |
| 350 // will vary the most between calls. If |direct| is false, the | 351 // will vary the most between calls. If |direct| is false, the |
| 351 // the full url will be used instead of simply the path. | 352 // the full url will be used instead of simply the path. |
| 352 // Returns a SpdySerializedFrame. | 353 // Returns a SpdySerializedFrame. |
| 353 SpdySerializedFrame ConstructSpdyGet(const char* const extra_headers[], | 354 SpdySerializedFrame ConstructSpdyGet(const char* const extra_headers[], |
| 354 int extra_header_count, | 355 int extra_header_count, |
| 355 int stream_id, | 356 int stream_id, |
| 356 RequestPriority request_priority, | 357 RequestPriority request_priority, |
| 357 bool direct); | 358 bool direct); |
| 358 | 359 |
| 359 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request. | 360 // Constructs a SPDY HEADERS frame for a CONNECT request. |
| 360 SpdySerializedFrame ConstructSpdyConnect(const char* const extra_headers[], | 361 SpdySerializedFrame ConstructSpdyConnect(const char* const extra_headers[], |
| 361 int extra_header_count, | 362 int extra_header_count, |
| 362 int stream_id, | 363 int stream_id, |
| 363 RequestPriority priority, | 364 RequestPriority priority, |
| 364 const HostPortPair& host_port_pair); | 365 const HostPortPair& host_port_pair); |
| 365 | 366 |
| 366 // Constructs a standard SPDY push SYN frame. | 367 // Constructs a SPDY PUSH_PROMISE frame. |
| 367 // |extra_headers| are the extra header-value pairs, which typically | 368 // |extra_headers| are the extra header-value pairs, which typically |
| 368 // will vary the most between calls. | 369 // will vary the most between calls. |
| 369 // Returns a SpdySerializedFrame. | 370 // Returns a SpdySerializedFrame. |
| 370 SpdySerializedFrame ConstructSpdyPush(const char* const extra_headers[], | 371 SpdySerializedFrame ConstructSpdyPush(const char* const extra_headers[], |
| 371 int extra_header_count, | 372 int extra_header_count, |
| 372 int stream_id, | 373 int stream_id, |
| 373 int associated_stream_id, | 374 int associated_stream_id, |
| 374 const char* url); | 375 const char* url); |
| 375 SpdySerializedFrame ConstructSpdyPush(const char* const extra_headers[], | 376 SpdySerializedFrame ConstructSpdyPush(const char* const extra_headers[], |
| 376 int extra_header_count, | 377 int extra_header_count, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 389 const char* const extra_headers[], | 390 const char* const extra_headers[], |
| 390 int extra_header_count); | 391 int extra_header_count); |
| 391 | 392 |
| 392 // Constructs a HEADERS frame with the request header compression context with | 393 // Constructs a HEADERS frame with the request header compression context with |
| 393 // END_STREAM flag set to |fin|. | 394 // END_STREAM flag set to |fin|. |
| 394 SpdySerializedFrame ConstructSpdyResponseHeaders(int stream_id, | 395 SpdySerializedFrame ConstructSpdyResponseHeaders(int stream_id, |
| 395 SpdyHeaderBlock headers, | 396 SpdyHeaderBlock headers, |
| 396 bool fin); | 397 bool fin); |
| 397 | 398 |
| 398 // Construct a HEADERS frame carrying exactly the given headers and priority. | 399 // Construct a HEADERS frame carrying exactly the given headers and priority. |
| 399 SpdySerializedFrame ConstructSpdySyn(int stream_id, | 400 SpdySerializedFrame ConstructSpdyHeaders(int stream_id, |
| 400 SpdyHeaderBlock headers, | 401 SpdyHeaderBlock headers, |
| 401 RequestPriority priority, | 402 RequestPriority priority, |
| 402 bool fin); | 403 bool fin); |
| 403 | 404 |
| 404 // Construct a reply HEADERS frame carrying exactly the given headers and the | 405 // Construct a reply HEADERS frame carrying exactly the given headers and the |
| 405 // default priority. | 406 // default priority. |
| 406 SpdySerializedFrame ConstructSpdyReply(int stream_id, | 407 SpdySerializedFrame ConstructSpdyReply(int stream_id, |
| 407 SpdyHeaderBlock headers); | 408 SpdyHeaderBlock headers); |
| 408 | 409 |
| 409 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET. | 410 // Constructs a standard SPDY HEADERS frame to match the SPDY GET. |
| 410 // |extra_headers| are the extra header-value pairs, which typically | 411 // |extra_headers| are the extra header-value pairs, which typically |
| 411 // will vary the most between calls. | 412 // will vary the most between calls. |
| 412 // Returns a SpdySerializedFrame. | 413 // Returns a SpdySerializedFrame. |
| 413 SpdySerializedFrame ConstructSpdyGetSynReply( | 414 SpdySerializedFrame ConstructSpdyGetReply(const char* const extra_headers[], |
| 414 const char* const extra_headers[], | 415 int extra_header_count, |
| 415 int extra_header_count, | 416 int stream_id); |
| 416 int stream_id); | |
| 417 | 417 |
| 418 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET. | 418 // Constructs a standard SPDY HEADERS frame to match the SPDY GET. |
| 419 // |extra_headers| are the extra header-value pairs, which typically | 419 // |extra_headers| are the extra header-value pairs, which typically |
| 420 // will vary the most between calls. | 420 // will vary the most between calls. |
| 421 // Returns a SpdySerializedFrame. | 421 // Returns a SpdySerializedFrame. |
| 422 SpdySerializedFrame ConstructSpdyGetSynReplyRedirect(int stream_id); | 422 SpdySerializedFrame ConstructSpdyGetReplyRedirect(int stream_id); |
| 423 | 423 |
| 424 // Constructs a standard SPDY SYN_REPLY frame with an Internal Server | 424 // Constructs a standard SPDY HEADERS frame with an Internal Server |
| 425 // Error status code. | 425 // Error status code. |
| 426 // Returns a SpdySerializedFrame. | 426 // Returns a SpdySerializedFrame. |
| 427 SpdySerializedFrame ConstructSpdySynReplyError(int stream_id); | 427 SpdySerializedFrame ConstructSpdyReplyError(int stream_id); |
| 428 | 428 |
| 429 // Constructs a standard SPDY SYN_REPLY frame with the specified status code. | 429 // Constructs a standard SPDY HEADERS frame with the specified status code. |
| 430 // Returns a SpdySerializedFrame. | 430 // Returns a SpdySerializedFrame. |
| 431 SpdySerializedFrame ConstructSpdySynReplyError( | 431 SpdySerializedFrame ConstructSpdyReplyError( |
| 432 const char* const status, | 432 const char* const status, |
| 433 const char* const* const extra_headers, | 433 const char* const* const extra_headers, |
| 434 int extra_header_count, | 434 int extra_header_count, |
| 435 int stream_id); | 435 int stream_id); |
| 436 | 436 |
| 437 // Constructs a standard SPDY POST SYN frame. | 437 // Constructs a standard SPDY POST HEADERS frame. |
| 438 // |extra_headers| are the extra header-value pairs, which typically | 438 // |extra_headers| are the extra header-value pairs, which typically |
| 439 // will vary the most between calls. | 439 // will vary the most between calls. |
| 440 // Returns a SpdySerializedFrame. | 440 // Returns a SpdySerializedFrame. |
| 441 SpdySerializedFrame ConstructSpdyPost(const char* url, | 441 SpdySerializedFrame ConstructSpdyPost(const char* url, |
| 442 SpdyStreamId stream_id, | 442 SpdyStreamId stream_id, |
| 443 int64_t content_length, | 443 int64_t content_length, |
| 444 RequestPriority priority, | 444 RequestPriority priority, |
| 445 const char* const extra_headers[], | 445 const char* const extra_headers[], |
| 446 int extra_header_count); | 446 int extra_header_count); |
| 447 | 447 |
| 448 // Constructs a chunked transfer SPDY POST SYN frame. | 448 // Constructs a chunked transfer SPDY POST HEADERS frame. |
| 449 // |extra_headers| are the extra header-value pairs, which typically | 449 // |extra_headers| are the extra header-value pairs, which typically |
| 450 // will vary the most between calls. | 450 // will vary the most between calls. |
| 451 // Returns a SpdySerializedFrame. | 451 // Returns a SpdySerializedFrame. |
| 452 SpdySerializedFrame ConstructChunkedSpdyPost( | 452 SpdySerializedFrame ConstructChunkedSpdyPost( |
| 453 const char* const extra_headers[], | 453 const char* const extra_headers[], |
| 454 int extra_header_count); | 454 int extra_header_count); |
| 455 | 455 |
| 456 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY POST. | 456 // Constructs a standard SPDY HEADERS frame to match the SPDY POST. |
| 457 // |extra_headers| are the extra header-value pairs, which typically | 457 // |extra_headers| are the extra header-value pairs, which typically |
| 458 // will vary the most between calls. | 458 // will vary the most between calls. |
| 459 // Returns a SpdySerializedFrame. | 459 // Returns a SpdySerializedFrame. |
| 460 SpdySerializedFrame ConstructSpdyPostSynReply( | 460 SpdySerializedFrame ConstructSpdyPostReply(const char* const extra_headers[], |
| 461 const char* const extra_headers[], | 461 int extra_header_count); |
| 462 int extra_header_count); | |
| 463 | 462 |
| 464 // Constructs a single SPDY data frame with the contents "hello!" | 463 // Constructs a single SPDY data frame with the contents "hello!" |
| 465 SpdySerializedFrame ConstructSpdyDataFrame(int stream_id, bool fin); | 464 SpdySerializedFrame ConstructSpdyDataFrame(int stream_id, bool fin); |
| 466 | 465 |
| 467 // Constructs a single SPDY data frame with the given content. | 466 // Constructs a single SPDY data frame with the given content. |
| 468 SpdySerializedFrame ConstructSpdyDataFrame(int stream_id, | 467 SpdySerializedFrame ConstructSpdyDataFrame(int stream_id, |
| 469 const char* data, | 468 const char* data, |
| 470 uint32_t len, | 469 uint32_t len, |
| 471 bool fin); | 470 bool fin); |
| 472 | 471 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 483 int stream_id); | 482 int stream_id); |
| 484 | 483 |
| 485 // Serialize a SpdyFrameIR with |headerless_spdy_framer_|. | 484 // Serialize a SpdyFrameIR with |headerless_spdy_framer_|. |
| 486 SpdySerializedFrame SerializeFrame(const SpdyFrameIR& frame_ir); | 485 SpdySerializedFrame SerializeFrame(const SpdyFrameIR& frame_ir); |
| 487 | 486 |
| 488 // Called when necessary (when it will affect stream dependency specification | 487 // Called when necessary (when it will affect stream dependency specification |
| 489 // when setting dependencies based on priorioties) to notify the utility | 488 // when setting dependencies based on priorioties) to notify the utility |
| 490 // class of stream destruction. | 489 // class of stream destruction. |
| 491 void UpdateWithStreamDestruction(int stream_id); | 490 void UpdateWithStreamDestruction(int stream_id); |
| 492 | 491 |
| 493 // Maps |priority| to SPDY priority, and sets it on |frame_ir|. | |
| 494 void SetPriority(RequestPriority priority, SpdySynStreamIR* frame_ir) const; | |
| 495 | |
| 496 void set_default_url(const GURL& url) { default_url_ = url; } | 492 void set_default_url(const GURL& url) { default_url_ = url; } |
| 497 | 493 |
| 498 const char* GetMethodKey() const; | 494 const char* GetMethodKey() const; |
| 499 const char* GetStatusKey() const; | 495 const char* GetStatusKey() const; |
| 500 const char* GetHostKey() const; | 496 const char* GetHostKey() const; |
| 501 const char* GetSchemeKey() const; | 497 const char* GetSchemeKey() const; |
| 502 const char* GetPathKey() const; | 498 const char* GetPathKey() const; |
| 503 | 499 |
| 504 private: | 500 private: |
| 505 // |content_length| may be NULL, in which case the content-length | 501 // |content_length| may be NULL, in which case the content-length |
| (...skipping 13 matching lines...) Expand all Loading... |
| 519 | 515 |
| 520 GURL default_url_; | 516 GURL default_url_; |
| 521 | 517 |
| 522 // Track a FIFO list of the stream_id of all created requests by priority. | 518 // Track a FIFO list of the stream_id of all created requests by priority. |
| 523 std::map<int, std::vector<int>> priority_to_stream_id_list_; | 519 std::map<int, std::vector<int>> priority_to_stream_id_list_; |
| 524 }; | 520 }; |
| 525 | 521 |
| 526 } // namespace net | 522 } // namespace net |
| 527 | 523 |
| 528 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 524 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
| OLD | NEW |