| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 291 |
| 292 SpdyHeaderBlock ConstructGetHeaderBlock(base::StringPiece url) const; | 292 SpdyHeaderBlock ConstructGetHeaderBlock(base::StringPiece url) const; |
| 293 SpdyHeaderBlock ConstructGetHeaderBlockForProxy(base::StringPiece url) const; | 293 SpdyHeaderBlock ConstructGetHeaderBlockForProxy(base::StringPiece url) const; |
| 294 SpdyHeaderBlock ConstructHeadHeaderBlock(base::StringPiece url, | 294 SpdyHeaderBlock ConstructHeadHeaderBlock(base::StringPiece url, |
| 295 int64_t content_length) const; | 295 int64_t content_length) const; |
| 296 SpdyHeaderBlock ConstructPostHeaderBlock(base::StringPiece url, | 296 SpdyHeaderBlock ConstructPostHeaderBlock(base::StringPiece url, |
| 297 int64_t content_length) const; | 297 int64_t content_length) const; |
| 298 SpdyHeaderBlock ConstructPutHeaderBlock(base::StringPiece url, | 298 SpdyHeaderBlock ConstructPutHeaderBlock(base::StringPiece url, |
| 299 int64_t content_length) const; | 299 int64_t content_length) const; |
| 300 | 300 |
| 301 // Construct a SPDY frame. If it is a SYN_STREAM or SYN_REPLY frame (as | |
| 302 // specified in header_info.kind), the provided headers are included in the | |
| 303 // frame. | |
| 304 SpdySerializedFrame* ConstructSpdyFrame(const SpdyHeaderInfo& header_info, | |
| 305 SpdyHeaderBlock headers) const; | |
| 306 | |
| 307 // Construct a SPDY frame. If it is a SYN_STREAM or SYN_REPLY frame (as | |
| 308 // specified in header_info.kind), the headers provided in extra_headers and | |
| 309 // (if non-NULL) tail_headers are concatenated and included in the frame. | |
| 310 // (extra_headers must always be non-NULL.) | |
| 311 SpdySerializedFrame* ConstructSpdyFrame(const SpdyHeaderInfo& header_info, | |
| 312 const char* const extra_headers[], | |
| 313 int extra_header_count, | |
| 314 const char* const tail_headers[], | |
| 315 int tail_header_count) const; | |
| 316 | |
| 317 // Construct an expected SPDY reply string from the given headers. | 301 // Construct an expected SPDY reply string from the given headers. |
| 318 std::string ConstructSpdyReplyString(const SpdyHeaderBlock& headers) const; | 302 std::string ConstructSpdyReplyString(const SpdyHeaderBlock& headers) const; |
| 319 | 303 |
| 320 // Construct an expected SPDY SETTINGS frame. | 304 // Construct an expected SPDY SETTINGS frame. |
| 321 // |settings| are the settings to set. | 305 // |settings| are the settings to set. |
| 322 // Returns the constructed frame. The caller takes ownership of the frame. | 306 // Returns the constructed frame. The caller takes ownership of the frame. |
| 323 SpdySerializedFrame* ConstructSpdySettings(const SettingsMap& settings); | 307 SpdySerializedFrame ConstructSpdySettings(const SettingsMap& settings); |
| 324 | 308 |
| 325 // Constructs an expected SPDY SETTINGS acknowledgement frame. | 309 // Constructs an expected SPDY SETTINGS acknowledgement frame. |
| 326 SpdySerializedFrame* ConstructSpdySettingsAck(); | 310 SpdySerializedFrame ConstructSpdySettingsAck(); |
| 327 | 311 |
| 328 // Construct a SPDY PING frame. | 312 // Construct a SPDY PING frame. |
| 329 // Returns the constructed frame. The caller takes ownership of the frame. | 313 // Returns the constructed frame. The caller takes ownership of the frame. |
| 330 SpdySerializedFrame* ConstructSpdyPing(uint32_t ping_id, bool is_ack); | 314 SpdySerializedFrame ConstructSpdyPing(uint32_t ping_id, bool is_ack); |
| 331 | 315 |
| 332 // Construct a SPDY GOAWAY frame with last_good_stream_id = 0. | 316 // Construct a SPDY GOAWAY frame with last_good_stream_id = 0. |
| 333 // Returns the constructed frame. The caller takes ownership of the frame. | 317 // Returns the constructed frame. The caller takes ownership of the frame. |
| 334 SpdySerializedFrame* ConstructSpdyGoAway(); | 318 SpdySerializedFrame ConstructSpdyGoAway(); |
| 335 | 319 |
| 336 // Construct a SPDY GOAWAY frame with the specified last_good_stream_id. | 320 // Construct a SPDY GOAWAY frame with the specified last_good_stream_id. |
| 337 // Returns the constructed frame. The caller takes ownership of the frame. | 321 // Returns the constructed frame. The caller takes ownership of the frame. |
| 338 SpdySerializedFrame* ConstructSpdyGoAway(SpdyStreamId last_good_stream_id); | 322 SpdySerializedFrame ConstructSpdyGoAway(SpdyStreamId last_good_stream_id); |
| 339 | 323 |
| 340 // Construct a SPDY GOAWAY frame with the specified last_good_stream_id, | 324 // Construct a SPDY GOAWAY frame with the specified last_good_stream_id, |
| 341 // status, and description. Returns the constructed frame. The caller takes | 325 // status, and description. Returns the constructed frame. The caller takes |
| 342 // ownership of the frame. | 326 // ownership of the frame. |
| 343 SpdySerializedFrame* ConstructSpdyGoAway(SpdyStreamId last_good_stream_id, | 327 SpdySerializedFrame ConstructSpdyGoAway(SpdyStreamId last_good_stream_id, |
| 344 SpdyGoAwayStatus status, | 328 SpdyGoAwayStatus status, |
| 345 const std::string& desc); | 329 const std::string& desc); |
| 346 | 330 |
| 347 // Construct a SPDY WINDOW_UPDATE frame. | 331 // Construct a SPDY WINDOW_UPDATE frame. |
| 348 // Returns the constructed frame. The caller takes ownership of the frame. | 332 // Returns the constructed frame. The caller takes ownership of the frame. |
| 349 SpdySerializedFrame* ConstructSpdyWindowUpdate(SpdyStreamId stream_id, | 333 SpdySerializedFrame ConstructSpdyWindowUpdate(SpdyStreamId stream_id, |
| 350 uint32_t delta_window_size); | 334 uint32_t delta_window_size); |
| 351 | 335 |
| 352 // Construct a SPDY RST_STREAM frame. | 336 // Construct a SPDY RST_STREAM frame. |
| 353 // Returns the constructed frame. The caller takes ownership of the frame. | 337 // Returns the constructed frame. The caller takes ownership of the frame. |
| 354 SpdySerializedFrame* ConstructSpdyRstStream(SpdyStreamId stream_id, | 338 SpdySerializedFrame ConstructSpdyRstStream(SpdyStreamId stream_id, |
| 355 SpdyRstStreamStatus status); | 339 SpdyRstStreamStatus status); |
| 356 | 340 |
| 357 // Constructs a standard SPDY GET SYN frame for |url| with header compression. | 341 // Constructs a standard SPDY GET SYN frame for |url| with header compression. |
| 358 // |extra_headers| are the extra header-value pairs, which typically | 342 // |extra_headers| are the extra header-value pairs, which typically |
| 359 // will vary the most between calls. | 343 // will vary the most between calls. |
| 360 // Returns a SpdySerializedFrame. | 344 // Returns a SpdySerializedFrame. |
| 361 SpdySerializedFrame* ConstructSpdyGet(const char* const url, | 345 SpdySerializedFrame ConstructSpdyGet(const char* const url, |
| 362 SpdyStreamId stream_id, | 346 SpdyStreamId stream_id, |
| 363 RequestPriority request_priority); | 347 RequestPriority request_priority); |
| 364 | 348 |
| 365 // Constructs a standard SPDY GET SYN frame with header compression. | 349 // Constructs a standard SPDY GET SYN frame with header compression. |
| 366 // |extra_headers| are the extra header-value pairs, which typically | 350 // |extra_headers| are the extra header-value pairs, which typically |
| 367 // will vary the most between calls. If |direct| is false, the | 351 // will vary the most between calls. If |direct| is false, the |
| 368 // the full url will be used instead of simply the path. | 352 // the full url will be used instead of simply the path. |
| 369 // Returns a SpdySerializedFrame. | 353 // Returns a SpdySerializedFrame. |
| 370 SpdySerializedFrame* ConstructSpdyGet(const char* const extra_headers[], | 354 SpdySerializedFrame ConstructSpdyGet(const char* const extra_headers[], |
| 371 int extra_header_count, | 355 int extra_header_count, |
| 372 int stream_id, | 356 int stream_id, |
| 373 RequestPriority request_priority, | 357 RequestPriority request_priority, |
| 374 bool direct); | 358 bool direct); |
| 375 | 359 |
| 376 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request. | 360 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request. |
| 377 SpdySerializedFrame* ConstructSpdyConnect(const char* const extra_headers[], | 361 SpdySerializedFrame ConstructSpdyConnect(const char* const extra_headers[], |
| 378 int extra_header_count, | 362 int extra_header_count, |
| 379 int stream_id, | 363 int stream_id, |
| 380 RequestPriority priority, | 364 RequestPriority priority, |
| 381 const HostPortPair& host_port_pair); | 365 const HostPortPair& host_port_pair); |
| 382 | 366 |
| 383 // Constructs a standard SPDY push SYN frame. | 367 // Constructs a standard SPDY push SYN frame. |
| 384 // |extra_headers| are the extra header-value pairs, which typically | 368 // |extra_headers| are the extra header-value pairs, which typically |
| 385 // will vary the most between calls. | 369 // will vary the most between calls. |
| 386 // Returns a SpdySerializedFrame. | 370 // Returns a SpdySerializedFrame. |
| 387 SpdySerializedFrame* ConstructSpdyPush(const char* const extra_headers[], | 371 SpdySerializedFrame ConstructSpdyPush(const char* const extra_headers[], |
| 388 int extra_header_count, | 372 int extra_header_count, |
| 389 int stream_id, | 373 int stream_id, |
| 390 int associated_stream_id, | 374 int associated_stream_id, |
| 391 const char* url); | 375 const char* url); |
| 392 SpdySerializedFrame* ConstructSpdyPush(const char* const extra_headers[], | 376 SpdySerializedFrame ConstructSpdyPush(const char* const extra_headers[], |
| 393 int extra_header_count, | 377 int extra_header_count, |
| 394 int stream_id, | 378 int stream_id, |
| 395 int associated_stream_id, | 379 int associated_stream_id, |
| 396 const char* url, | 380 const char* url, |
| 397 const char* status, | 381 const char* status, |
| 398 const char* location); | 382 const char* location); |
| 399 | 383 |
| 400 SpdySerializedFrame* ConstructInitialSpdyPushFrame(SpdyHeaderBlock headers, | 384 SpdySerializedFrame ConstructInitialSpdyPushFrame(SpdyHeaderBlock headers, |
| 401 int stream_id, | 385 int stream_id, |
| 402 int associated_stream_id); | 386 int associated_stream_id); |
| 403 | 387 |
| 404 SpdySerializedFrame* ConstructSpdyPushHeaders( | 388 SpdySerializedFrame ConstructSpdyPushHeaders( |
| 405 int stream_id, | 389 int stream_id, |
| 406 const char* const extra_headers[], | 390 const char* const extra_headers[], |
| 407 int extra_header_count); | 391 int extra_header_count); |
| 408 | 392 |
| 409 // Constructs a HEADERS frame with the request header compression context with | 393 // Constructs a HEADERS frame with the request header compression context with |
| 410 // END_STREAM flag set to |fin|. | 394 // END_STREAM flag set to |fin|. |
| 411 SpdySerializedFrame* ConstructSpdyResponseHeaders(int stream_id, | 395 SpdySerializedFrame ConstructSpdyResponseHeaders(int stream_id, |
| 412 SpdyHeaderBlock headers, | 396 SpdyHeaderBlock headers, |
| 413 bool fin); | 397 bool fin); |
| 414 | 398 |
| 415 // Construct a HEADERS frame carrying exactly the given headers and priority. | 399 // Construct a HEADERS frame carrying exactly the given headers and priority. |
| 416 SpdySerializedFrame* ConstructSpdySyn(int stream_id, | 400 SpdySerializedFrame ConstructSpdySyn(int stream_id, |
| 417 SpdyHeaderBlock headers, | 401 SpdyHeaderBlock headers, |
| 418 RequestPriority priority, | 402 RequestPriority priority, |
| 419 bool fin); | 403 bool fin); |
| 420 | 404 |
| 421 // 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 |
| 422 // default priority. | 406 // default priority. |
| 423 SpdySerializedFrame* ConstructSpdyReply(int stream_id, | 407 SpdySerializedFrame ConstructSpdyReply(int stream_id, |
| 424 SpdyHeaderBlock headers); | 408 SpdyHeaderBlock headers); |
| 425 | 409 |
| 426 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET. | 410 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET. |
| 427 // |extra_headers| are the extra header-value pairs, which typically | 411 // |extra_headers| are the extra header-value pairs, which typically |
| 428 // will vary the most between calls. | 412 // will vary the most between calls. |
| 429 // Returns a SpdySerializedFrame. | 413 // Returns a SpdySerializedFrame. |
| 430 SpdySerializedFrame* ConstructSpdyGetSynReply( | 414 SpdySerializedFrame ConstructSpdyGetSynReply( |
| 431 const char* const extra_headers[], | 415 const char* const extra_headers[], |
| 432 int extra_header_count, | 416 int extra_header_count, |
| 433 int stream_id); | 417 int stream_id); |
| 434 | 418 |
| 435 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET. | 419 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET. |
| 436 // |extra_headers| are the extra header-value pairs, which typically | 420 // |extra_headers| are the extra header-value pairs, which typically |
| 437 // will vary the most between calls. | 421 // will vary the most between calls. |
| 438 // Returns a SpdySerializedFrame. | 422 // Returns a SpdySerializedFrame. |
| 439 SpdySerializedFrame* ConstructSpdyGetSynReplyRedirect(int stream_id); | 423 SpdySerializedFrame ConstructSpdyGetSynReplyRedirect(int stream_id); |
| 440 | 424 |
| 441 // Constructs a standard SPDY SYN_REPLY frame with an Internal Server | 425 // Constructs a standard SPDY SYN_REPLY frame with an Internal Server |
| 442 // Error status code. | 426 // Error status code. |
| 443 // Returns a SpdySerializedFrame. | 427 // Returns a SpdySerializedFrame. |
| 444 SpdySerializedFrame* ConstructSpdySynReplyError(int stream_id); | 428 SpdySerializedFrame ConstructSpdySynReplyError(int stream_id); |
| 445 | 429 |
| 446 // Constructs a standard SPDY SYN_REPLY frame with the specified status code. | 430 // Constructs a standard SPDY SYN_REPLY frame with the specified status code. |
| 447 // Returns a SpdySerializedFrame. | 431 // Returns a SpdySerializedFrame. |
| 448 SpdySerializedFrame* ConstructSpdySynReplyError( | 432 SpdySerializedFrame ConstructSpdySynReplyError( |
| 449 const char* const status, | 433 const char* const status, |
| 450 const char* const* const extra_headers, | 434 const char* const* const extra_headers, |
| 451 int extra_header_count, | 435 int extra_header_count, |
| 452 int stream_id); | 436 int stream_id); |
| 453 | 437 |
| 454 // Constructs a standard SPDY POST SYN frame. | 438 // Constructs a standard SPDY POST SYN frame. |
| 455 // |extra_headers| are the extra header-value pairs, which typically | 439 // |extra_headers| are the extra header-value pairs, which typically |
| 456 // will vary the most between calls. | 440 // will vary the most between calls. |
| 457 // Returns a SpdySerializedFrame. | 441 // Returns a SpdySerializedFrame. |
| 458 SpdySerializedFrame* ConstructSpdyPost(const char* url, | 442 SpdySerializedFrame ConstructSpdyPost(const char* url, |
| 459 SpdyStreamId stream_id, | 443 SpdyStreamId stream_id, |
| 460 int64_t content_length, | 444 int64_t content_length, |
| 461 RequestPriority priority, | 445 RequestPriority priority, |
| 462 const char* const extra_headers[], | 446 const char* const extra_headers[], |
| 463 int extra_header_count); | 447 int extra_header_count); |
| 464 | 448 |
| 465 // Constructs a chunked transfer SPDY POST SYN frame. | 449 // Constructs a chunked transfer SPDY POST SYN frame. |
| 466 // |extra_headers| are the extra header-value pairs, which typically | 450 // |extra_headers| are the extra header-value pairs, which typically |
| 467 // will vary the most between calls. | 451 // will vary the most between calls. |
| 468 // Returns a SpdySerializedFrame. | 452 // Returns a SpdySerializedFrame. |
| 469 SpdySerializedFrame* ConstructChunkedSpdyPost( | 453 SpdySerializedFrame ConstructChunkedSpdyPost( |
| 470 const char* const extra_headers[], | 454 const char* const extra_headers[], |
| 471 int extra_header_count); | 455 int extra_header_count); |
| 472 | 456 |
| 473 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY POST. | 457 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY POST. |
| 474 // |extra_headers| are the extra header-value pairs, which typically | 458 // |extra_headers| are the extra header-value pairs, which typically |
| 475 // will vary the most between calls. | 459 // will vary the most between calls. |
| 476 // Returns a SpdySerializedFrame. | 460 // Returns a SpdySerializedFrame. |
| 477 SpdySerializedFrame* ConstructSpdyPostSynReply( | 461 SpdySerializedFrame ConstructSpdyPostSynReply( |
| 478 const char* const extra_headers[], | 462 const char* const extra_headers[], |
| 479 int extra_header_count); | 463 int extra_header_count); |
| 480 | 464 |
| 481 // Constructs a single SPDY data frame with the contents "hello!" | 465 // Constructs a single SPDY data frame with the contents "hello!" |
| 482 SpdySerializedFrame* ConstructSpdyBodyFrame(int stream_id, bool fin); | 466 SpdySerializedFrame ConstructSpdyDataFrame(int stream_id, bool fin); |
| 483 | 467 |
| 484 // Constructs a single SPDY data frame with the given content. | 468 // Constructs a single SPDY data frame with the given content. |
| 485 SpdySerializedFrame* ConstructSpdyBodyFrame(int stream_id, | 469 SpdySerializedFrame ConstructSpdyDataFrame(int stream_id, |
| 486 const char* data, | 470 const char* data, |
| 487 uint32_t len, | 471 uint32_t len, |
| 488 bool fin); | 472 bool fin); |
| 489 | 473 |
| 490 // Constructs a single SPDY data frame with the given content and padding. | 474 // Constructs a single SPDY data frame with the given content and padding. |
| 491 SpdySerializedFrame* ConstructSpdyBodyFrame(int stream_id, | 475 SpdySerializedFrame ConstructSpdyDataFrame(int stream_id, |
| 492 const char* data, | 476 const char* data, |
| 493 uint32_t len, | 477 uint32_t len, |
| 494 bool fin, | 478 bool fin, |
| 495 int padding_length); | 479 int padding_length); |
| 496 | 480 |
| 497 // Wraps |frame| in the payload of a data frame in stream |stream_id|. | 481 // Wraps |frame| in the payload of a data frame in stream |stream_id|. |
| 498 SpdySerializedFrame* ConstructWrappedSpdyFrame( | 482 SpdySerializedFrame ConstructWrappedSpdyFrame( |
| 499 const std::unique_ptr<SpdySerializedFrame>& frame, | 483 const SpdySerializedFrame& frame, |
| 500 int stream_id); | 484 int stream_id); |
| 501 | 485 |
| 502 // Serialize a SpdyFrameIR with |headerless_spdy_framer_|. | 486 // Serialize a SpdyFrameIR with |headerless_spdy_framer_|. |
| 503 SpdySerializedFrame SerializeFrame(const SpdyFrameIR& frame_ir); | 487 SpdySerializedFrame SerializeFrame(const SpdyFrameIR& frame_ir); |
| 504 | 488 |
| 505 // Called when necessary (when it will affect stream dependency specification | 489 // Called when necessary (when it will affect stream dependency specification |
| 506 // when setting dependencies based on priorioties) to notify the utility | 490 // when setting dependencies based on priorioties) to notify the utility |
| 507 // class of stream destruction. | 491 // class of stream destruction. |
| 508 void UpdateWithStreamDestruction(int stream_id); | 492 void UpdateWithStreamDestruction(int stream_id); |
| 509 | 493 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 537 GURL default_url_; | 521 GURL default_url_; |
| 538 bool dependency_priorities_; | 522 bool dependency_priorities_; |
| 539 | 523 |
| 540 // Track a FIFO list of the stream_id of all created requests by priority. | 524 // Track a FIFO list of the stream_id of all created requests by priority. |
| 541 std::map<int, std::vector<int>> priority_to_stream_id_list_; | 525 std::map<int, std::vector<int>> priority_to_stream_id_list_; |
| 542 }; | 526 }; |
| 543 | 527 |
| 544 } // namespace net | 528 } // namespace net |
| 545 | 529 |
| 546 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 530 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
| OLD | NEW |