Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Side by Side Diff: net/spdy/spdy_network_transaction_spdy3_unittest.cc

Issue 9958023: Properly handle spdy3 responses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 0, // Associated stream ID 1471 0, // Associated stream ID
1472 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority 1472 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
1473 0, // Credential Slot 1473 0, // Credential Slot
1474 CONTROL_FLAG_NONE, // Control Flags 1474 CONTROL_FLAG_NONE, // Control Flags
1475 false, // Compressed 1475 false, // Compressed
1476 INVALID, // Status 1476 INVALID, // Status
1477 NULL, // Data 1477 NULL, // Data
1478 0, // Length 1478 0, // Length
1479 DATA_FLAG_NONE // Data Flags 1479 DATA_FLAG_NONE // Data Flags
1480 }; 1480 };
1481 static const char* const kStandardGetHeaders[] = { 1481 static const char* const kStandardRespHeaders[] = {
1482 "status", "200", 1482 ":status", "200",
1483 "version", "HTTP/1.1" 1483 ":version", "HTTP/1.1"
1484 "content-length", "1234" 1484 "content-length", "1234"
1485 }; 1485 };
1486 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader, 1486 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader,
1487 NULL, 0, kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2)); 1487 NULL, 0, kStandardRespHeaders, arraysize(kStandardRespHeaders) / 2));
1488 MockRead reads[] = { 1488 MockRead reads[] = {
1489 CreateMockRead(*resp), 1489 CreateMockRead(*resp),
1490 CreateMockRead(*body), 1490 CreateMockRead(*body),
1491 MockRead(ASYNC, 0, 0) // EOF 1491 MockRead(ASYNC, 0, 0) // EOF
1492 }; 1492 };
1493 1493
1494 scoped_ptr<DelayedSocketData> data( 1494 scoped_ptr<DelayedSocketData> data(
1495 new DelayedSocketData(1, reads, arraysize(reads), 1495 new DelayedSocketData(1, reads, arraysize(reads),
1496 writes, arraysize(writes))); 1496 writes, arraysize(writes)));
1497 NormalSpdyTransactionHelper helper(request, 1497 NormalSpdyTransactionHelper helper(request,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 0, // Associated stream ID 1544 0, // Associated stream ID
1545 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority 1545 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
1546 0, // Credential Slot 1546 0, // Credential Slot
1547 CONTROL_FLAG_NONE, // Control Flags 1547 CONTROL_FLAG_NONE, // Control Flags
1548 false, // Compressed 1548 false, // Compressed
1549 INVALID, // Status 1549 INVALID, // Status
1550 NULL, // Data 1550 NULL, // Data
1551 0, // Length 1551 0, // Length
1552 DATA_FLAG_NONE // Data Flags 1552 DATA_FLAG_NONE // Data Flags
1553 }; 1553 };
1554 static const char* const kStandardGetHeaders[] = { 1554 static const char* const kStandardRespHeaders[] = {
1555 "status", "200", 1555 ":status", "200",
1556 "version", "HTTP/1.1" 1556 ":version", "HTTP/1.1"
1557 "content-length", "1234" 1557 "content-length", "1234"
1558 }; 1558 };
1559 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader, 1559 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader,
1560 NULL, 0, kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2)); 1560 NULL, 0, kStandardRespHeaders, arraysize(kStandardRespHeaders) / 2));
1561 MockRead reads[] = { 1561 MockRead reads[] = {
1562 CreateMockRead(*resp), 1562 CreateMockRead(*resp),
1563 CreateMockRead(*body), 1563 CreateMockRead(*body),
1564 MockRead(ASYNC, 0, 0) // EOF 1564 MockRead(ASYNC, 0, 0) // EOF
1565 }; 1565 };
1566 1566
1567 scoped_ptr<DelayedSocketData> data( 1567 scoped_ptr<DelayedSocketData> data(
1568 new DelayedSocketData(1, reads, arraysize(reads), 1568 new DelayedSocketData(1, reads, arraysize(reads),
1569 writes, arraysize(writes))); 1569 writes, arraysize(writes)));
1570 NormalSpdyTransactionHelper helper(request, 1570 NormalSpdyTransactionHelper helper(request,
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 TEST_P(SpdyNetworkTransactionSpdy3Test, ResetPushWithTransferEncoding) { 2263 TEST_P(SpdyNetworkTransactionSpdy3Test, ResetPushWithTransferEncoding) {
2264 // Construct the request. 2264 // Construct the request.
2265 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2265 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2266 scoped_ptr<SpdyFrame> rst(ConstructSpdyRstStream(2, PROTOCOL_ERROR)); 2266 scoped_ptr<SpdyFrame> rst(ConstructSpdyRstStream(2, PROTOCOL_ERROR));
2267 MockWrite writes[] = { 2267 MockWrite writes[] = {
2268 CreateMockWrite(*req), 2268 CreateMockWrite(*req),
2269 CreateMockWrite(*rst), 2269 CreateMockWrite(*rst),
2270 }; 2270 };
2271 2271
2272 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 2272 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
2273 const char* const headers[] = {"url", "http://www.google.com/1", 2273 const char* const headers[] = {":scheme", "http",
2274 ":host", "www.google.com",
2275 ":path", "/1",
2274 "transfer-encoding", "chunked"}; 2276 "transfer-encoding", "chunked"};
2275 scoped_ptr<SpdyFrame> push(ConstructSpdyPush(headers, arraysize(headers) / 2, 2277 scoped_ptr<SpdyFrame> push(ConstructSpdyPush(headers, arraysize(headers) / 2,
2276 2, 1)); 2278 2, 1));
2277 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 2279 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
2278 MockRead reads[] = { 2280 MockRead reads[] = {
2279 CreateMockRead(*resp), 2281 CreateMockRead(*resp),
2280 CreateMockRead(*push), 2282 CreateMockRead(*push),
2281 CreateMockRead(*body), 2283 CreateMockRead(*body),
2282 MockRead(ASYNC, 0, 0) // EOF 2284 MockRead(ASYNC, 0, 0) // EOF
2283 }; 2285 };
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2571 new SpdyURLRequestContext(); 2573 new SpdyURLRequestContext();
2572 r.set_context(spdy_url_request_context); 2574 r.set_context(spdy_url_request_context);
2573 spdy_url_request_context->socket_factory(). 2575 spdy_url_request_context->socket_factory().
2574 AddSocketDataProvider(data.get()); 2576 AddSocketDataProvider(data.get());
2575 spdy_url_request_context->socket_factory(). 2577 spdy_url_request_context->socket_factory().
2576 AddSocketDataProvider(data2.get()); 2578 AddSocketDataProvider(data2.get());
2577 2579
2578 d.set_quit_on_redirect(true); 2580 d.set_quit_on_redirect(true);
2579 r.Start(); 2581 r.Start();
2580 MessageLoop::current()->Run(); 2582 MessageLoop::current()->Run();
2581
2582 EXPECT_EQ(1, d.received_redirect_count()); 2583 EXPECT_EQ(1, d.received_redirect_count());
2583 2584
2584 r.FollowDeferredRedirect(); 2585 r.FollowDeferredRedirect();
2585 MessageLoop::current()->Run(); 2586 MessageLoop::current()->Run();
2586 EXPECT_EQ(1, d.response_started_count()); 2587 EXPECT_EQ(1, d.response_started_count());
2587 EXPECT_FALSE(d.received_data_before_response()); 2588 EXPECT_FALSE(d.received_data_before_response());
2588 EXPECT_EQ(net::URLRequestStatus::SUCCESS, r.status().status()); 2589 EXPECT_EQ(net::URLRequestStatus::SUCCESS, r.status().status());
2589 std::string contents("hello!"); 2590 std::string contents("hello!");
2590 EXPECT_EQ(contents, d.data_received()); 2591 EXPECT_EQ(contents, d.data_received());
2591 } 2592 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2634 scoped_ptr<SpdyFrame> 2635 scoped_ptr<SpdyFrame>
2635 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2636 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2636 scoped_ptr<SpdyFrame> 2637 scoped_ptr<SpdyFrame>
2637 rst(ConstructSpdyRstStream(1, PROTOCOL_ERROR)); 2638 rst(ConstructSpdyRstStream(1, PROTOCOL_ERROR));
2638 MockWrite writes[] = { 2639 MockWrite writes[] = {
2639 CreateMockWrite(*syn, 0), 2640 CreateMockWrite(*syn, 0),
2640 CreateMockWrite(*rst, 2), 2641 CreateMockWrite(*rst, 2),
2641 }; 2642 };
2642 2643
2643 static const char* const kInitialHeaders[] = { 2644 static const char* const kInitialHeaders[] = {
2644 "status", "200 OK", 2645 ":status", "200 OK",
2645 "version", "HTTP/1.1" 2646 ":version", "HTTP/1.1"
2646 }; 2647 };
2647 static const char* const kLateHeaders[] = { 2648 static const char* const kLateHeaders[] = {
2648 "X-UpperCase", "yes", 2649 "X-UpperCase", "yes",
2649 }; 2650 };
2650 scoped_ptr<SpdyFrame> 2651 scoped_ptr<SpdyFrame>
2651 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders, 2652 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders,
2652 arraysize(kInitialHeaders) / 2, 2653 arraysize(kInitialHeaders) / 2,
2653 false, 2654 false,
2654 1, 2655 1,
2655 LOWEST, 2656 LOWEST,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2693 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2694 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2694 scoped_ptr<SpdyFrame> 2695 scoped_ptr<SpdyFrame>
2695 rst(ConstructSpdyRstStream(2, PROTOCOL_ERROR)); 2696 rst(ConstructSpdyRstStream(2, PROTOCOL_ERROR));
2696 MockWrite writes[] = { 2697 MockWrite writes[] = {
2697 CreateMockWrite(*syn, 0), 2698 CreateMockWrite(*syn, 0),
2698 CreateMockWrite(*rst, 2), 2699 CreateMockWrite(*rst, 2),
2699 }; 2700 };
2700 2701
2701 scoped_ptr<SpdyFrame> 2702 scoped_ptr<SpdyFrame>
2702 reply(ConstructSpdyGetSynReply(NULL, 0, 1)); 2703 reply(ConstructSpdyGetSynReply(NULL, 0, 1));
2703 const char* const extra_headers[] = {"X-UpperCase", "yes"}; 2704 const char* const extra_headers[] = {
2705 "X-UpperCase", "yes"
2706 };
2704 scoped_ptr<SpdyFrame> 2707 scoped_ptr<SpdyFrame>
2705 push(ConstructSpdyPush(extra_headers, 1, 2, 1)); 2708 push(ConstructSpdyPush(extra_headers, arraysize(extra_headers)/2, 2, 1));
ramant (doing other things) 2012/03/30 22:19:58 nit: " arraysize(extra_headers)/2" -> " arraysize(
Ryan Hamilton 2012/03/30 22:46:02 Done.
2706 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 2709 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
2707 MockRead reads[] = { 2710 MockRead reads[] = {
2708 CreateMockRead(*reply, 1), 2711 CreateMockRead(*reply, 1),
2709 CreateMockRead(*push, 1), 2712 CreateMockRead(*push, 1),
2710 CreateMockRead(*body, 1), 2713 CreateMockRead(*body, 1),
2711 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause 2714 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause
2712 }; 2715 };
2713 2716
2714 HttpResponseInfo response; 2717 HttpResponseInfo response;
2715 HttpResponseInfo response2; 2718 HttpResponseInfo response2;
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
3466 int num_headers; 3469 int num_headers;
3467 const char* extra_headers[5]; 3470 const char* extra_headers[5];
3468 const char* expected_headers; 3471 const char* expected_headers;
3469 } test_cases[] = { 3472 } test_cases[] = {
3470 // This uses a multi-valued cookie header. 3473 // This uses a multi-valued cookie header.
3471 { 2, 3474 { 2,
3472 { "cookie", "val1", 3475 { "cookie", "val1",
3473 "cookie", "val2", // will get appended separated by NULL 3476 "cookie", "val2", // will get appended separated by NULL
3474 NULL 3477 NULL
3475 }, 3478 },
3479 "status: 200\n"
3480 "version: HTTP/1.1\n"
3476 "cookie: val1\n" 3481 "cookie: val1\n"
3477 "cookie: val2\n" 3482 "cookie: val2\n"
3478 "hello: bye\n" 3483 "hello: bye\n"
3479 "status: 200\n"
3480 "version: HTTP/1.1\n"
3481 }, 3484 },
3482 // This is the minimalist set of headers. 3485 // This is the minimalist set of headers.
3483 { 0, 3486 { 0,
3484 { NULL }, 3487 { NULL },
3485 "hello: bye\n"
3486 "status: 200\n" 3488 "status: 200\n"
3487 "version: HTTP/1.1\n" 3489 "version: HTTP/1.1\n"
3490 "hello: bye\n"
3488 }, 3491 },
3489 // Headers with a comma separated list. 3492 // Headers with a comma separated list.
3490 { 1, 3493 { 1,
3491 { "cookie", "val1,val2", 3494 { "cookie", "val1,val2",
3492 NULL 3495 NULL
3493 }, 3496 },
3497 "status: 200\n"
3498 "version: HTTP/1.1\n"
3494 "cookie: val1,val2\n" 3499 "cookie: val1,val2\n"
3495 "hello: bye\n" 3500 "hello: bye\n"
3496 "status: 200\n"
3497 "version: HTTP/1.1\n"
3498 } 3501 }
3499 }; 3502 };
3500 3503
3501 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 3504 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
3502 scoped_ptr<SpdyFrame> req( 3505 scoped_ptr<SpdyFrame> req(
3503 ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 3506 ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
3504 MockWrite writes[] = { CreateMockWrite(*req) }; 3507 MockWrite writes[] = { CreateMockWrite(*req) };
3505 3508
3506 scoped_ptr<SpdyFrame> resp( 3509 scoped_ptr<SpdyFrame> resp(
3507 ConstructSpdyGetSynReply(test_cases[i].extra_headers, 3510 ConstructSpdyGetSynReply(test_cases[i].extra_headers,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3565 } test_cases[] = { 3568 } test_cases[] = {
3566 // Test the case of a multi-valued cookie. When the value is delimited 3569 // Test the case of a multi-valued cookie. When the value is delimited
3567 // with NUL characters, it needs to be unfolded into multiple headers. 3570 // with NUL characters, it needs to be unfolded into multiple headers.
3568 { 3571 {
3569 &syn_reply_info, 3572 &syn_reply_info,
3570 true, 3573 true,
3571 { 1, 4 }, 3574 { 1, 4 },
3572 { { "cookie", "val1,val2", 3575 { { "cookie", "val1,val2",
3573 NULL 3576 NULL
3574 }, 3577 },
3575 { "vary", "cookie", 3578 { ":status", "200",
3576 "status", "200", 3579 ":version", "HTTP/1.1",
3580 "vary", "cookie",
3577 "url", "/index.php", 3581 "url", "/index.php",
3578 "version", "HTTP/1.1",
3579 NULL 3582 NULL
3580 } 3583 }
3581 } 3584 }
3582 }, { // Multiple vary fields. 3585 }, { // Multiple vary fields.
3583 &syn_reply_info, 3586 &syn_reply_info,
3584 true, 3587 true,
3585 { 2, 5 }, 3588 { 2, 5 },
3586 { { "friend", "barney", 3589 { { "friend", "barney",
3587 "enemy", "snaggletooth", 3590 "enemy", "snaggletooth",
3588 NULL 3591 NULL
3589 }, 3592 },
3590 { "vary", "friend", 3593 { ":status", "200",
3594 ":version", "HTTP/1.1",
3595 "vary", "friend",
3591 "vary", "enemy", 3596 "vary", "enemy",
3592 "status", "200",
3593 "url", "/index.php", 3597 "url", "/index.php",
3594 "version", "HTTP/1.1",
3595 NULL 3598 NULL
3596 } 3599 }
3597 } 3600 }
3598 }, { // Test a '*' vary field. 3601 }, { // Test a '*' vary field.
3599 &syn_reply_info, 3602 &syn_reply_info,
3600 false, 3603 false,
3601 { 1, 4 }, 3604 { 1, 4 },
3602 { { "cookie", "val1,val2", 3605 { { "cookie", "val1,val2",
3603 NULL 3606 NULL
3604 }, 3607 },
3605 { "vary", "*", 3608 { ":status", "200",
3606 "status", "200", 3609 ":version", "HTTP/1.1",
3610 "vary", "*",
3607 "url", "/index.php", 3611 "url", "/index.php",
3608 "version", "HTTP/1.1",
3609 NULL 3612 NULL
3610 } 3613 }
3611 } 3614 }
3612 }, { // Multiple comma-separated vary fields. 3615 }, { // Multiple comma-separated vary fields.
3613 &syn_reply_info, 3616 &syn_reply_info,
3614 true, 3617 true,
3615 { 2, 4 }, 3618 { 2, 4 },
3616 { { "friend", "barney", 3619 { { "friend", "barney",
3617 "enemy", "snaggletooth", 3620 "enemy", "snaggletooth",
3618 NULL 3621 NULL
3619 }, 3622 },
3620 { "vary", "friend,enemy", 3623 { ":status", "200",
3621 "status", "200", 3624 ":version", "HTTP/1.1",
3625 "vary", "friend,enemy",
3622 "url", "/index.php", 3626 "url", "/index.php",
3623 "version", "HTTP/1.1",
3624 NULL 3627 NULL
3625 } 3628 }
3626 } 3629 }
3627 } 3630 }
3628 }; 3631 };
3629 3632
3630 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 3633 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
3631 // Construct the request. 3634 // Construct the request.
3632 scoped_ptr<SpdyFrame> frame_req( 3635 scoped_ptr<SpdyFrame> frame_req(
3633 ConstructSpdyGet(test_cases[i].extra_headers[0], 3636 ConstructSpdyGet(test_cases[i].extra_headers[0],
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
3734 { 4, 3737 { 4,
3735 { "cookie", "val1", 3738 { "cookie", "val1",
3736 "cookie", "val2", 3739 "cookie", "val2",
3737 "url", "/index.php", 3740 "url", "/index.php",
3738 "version", "HTTP/1.1", 3741 "version", "HTTP/1.1",
3739 NULL 3742 NULL
3740 }, 3743 },
3741 }, 3744 },
3742 // SYN_REPLY missing version header 3745 // SYN_REPLY missing version header
3743 { 2, 3746 { 2,
3744 { "status", "200", 3747 { ":status", "200",
3745 "url", "/index.php", 3748 "url", "/index.php",
3746 NULL 3749 NULL
3747 }, 3750 },
3748 }, 3751 },
3749 // SYN_REPLY with no headers 3752 // SYN_REPLY with no headers
3750 { 0, { NULL }, }, 3753 { 0, { NULL }, },
3751 }; 3754 };
3752 3755
3753 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 3756 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
3754 scoped_ptr<SpdyFrame> req( 3757 scoped_ptr<SpdyFrame> req(
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
4440 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority 4443 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
4441 0, // Credential Slot 4444 0, // Credential Slot
4442 CONTROL_FLAG_NONE, // Control Flags 4445 CONTROL_FLAG_NONE, // Control Flags
4443 false, // Compressed 4446 false, // Compressed
4444 INVALID, // Status 4447 INVALID, // Status
4445 NULL, // Data 4448 NULL, // Data
4446 0, // Data Length 4449 0, // Data Length
4447 DATA_FLAG_NONE // Data Flags 4450 DATA_FLAG_NONE // Data Flags
4448 }; 4451 };
4449 static const char* const kExtraHeaders[] = { 4452 static const char* const kExtraHeaders[] = {
4450 "status", "200", 4453 ":status", "200",
4451 "version", "HTTP/1.1" 4454 ":version", "HTTP/1.1"
4452 }; 4455 };
4453 4456
4454 BoundNetLog net_log; 4457 BoundNetLog net_log;
4455 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam()); 4458 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam());
4456 helper.RunPreTestSetup(); 4459 helper.RunPreTestSetup();
4457 4460
4458 // Verify that no settings exist initially. 4461 // Verify that no settings exist initially.
4459 HostPortPair host_port_pair("www.google.com", helper.port()); 4462 HostPortPair host_port_pair("www.google.com", helper.port());
4460 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); 4463 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool();
4461 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( 4464 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings(
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
4547 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority 4550 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
4548 0, // Credential Slot 4551 0, // Credential Slot
4549 CONTROL_FLAG_NONE, // Control Flags 4552 CONTROL_FLAG_NONE, // Control Flags
4550 false, // Compressed 4553 false, // Compressed
4551 INVALID, // Status 4554 INVALID, // Status
4552 NULL, // Data 4555 NULL, // Data
4553 0, // Data Length 4556 0, // Data Length
4554 DATA_FLAG_NONE // Data Flags 4557 DATA_FLAG_NONE // Data Flags
4555 }; 4558 };
4556 static const char* kExtraHeaders[] = { 4559 static const char* kExtraHeaders[] = {
4557 "status", "200", 4560 ":status", "200",
4558 "version", "HTTP/1.1" 4561 ":version", "HTTP/1.1"
4559 }; 4562 };
4560 4563
4561 BoundNetLog net_log; 4564 BoundNetLog net_log;
4562 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam()); 4565 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam());
4563 helper.RunPreTestSetup(); 4566 helper.RunPreTestSetup();
4564 4567
4565 // Verify that no settings exist initially. 4568 // Verify that no settings exist initially.
4566 HostPortPair host_port_pair("www.google.com", helper.port()); 4569 HostPortPair host_port_pair("www.google.com", helper.port());
4567 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); 4570 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool();
4568 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( 4571 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings(
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
5231 }; 5234 };
5232 scoped_ptr<SpdyFrame> 5235 scoped_ptr<SpdyFrame>
5233 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5236 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5234 scoped_ptr<SpdyFrame> 5237 scoped_ptr<SpdyFrame>
5235 stream1_body(ConstructSpdyBodyFrame(1, true)); 5238 stream1_body(ConstructSpdyBodyFrame(1, true));
5236 MockWrite writes[] = { 5239 MockWrite writes[] = {
5237 CreateMockWrite(*stream1_syn, 1), 5240 CreateMockWrite(*stream1_syn, 1),
5238 }; 5241 };
5239 5242
5240 static const char* const kInitialHeaders[] = { 5243 static const char* const kInitialHeaders[] = {
5241 "url", 5244 ":scheme", "http",
5242 "http://www.google.com/foo.dat", 5245 ":host", "www.google.com",
5246 ":path", "/foo.dat",
5243 }; 5247 };
5244 static const char* const kLateHeaders[] = { 5248 static const char* const kLateHeaders[] = {
5245 "hello", 5249 "hello",
5246 "bye", 5250 "bye",
5247 "status", 5251 ":status",
5248 "200", 5252 "200",
5249 "version", 5253 ":version",
5250 "HTTP/1.1" 5254 "HTTP/1.1"
5251 }; 5255 };
5252 scoped_ptr<SpdyFrame> 5256 scoped_ptr<SpdyFrame>
5253 stream2_syn(ConstructSpdyControlFrame(kInitialHeaders, 5257 stream2_syn(ConstructSpdyControlFrame(kInitialHeaders,
5254 arraysize(kInitialHeaders) / 2, 5258 arraysize(kInitialHeaders) / 2,
5255 false, 5259 false,
5256 2, 5260 2,
5257 LOWEST, 5261 LOWEST,
5258 SYN_STREAM, 5262 SYN_STREAM,
5259 CONTROL_FLAG_NONE, 5263 CONTROL_FLAG_NONE,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5315 }; 5319 };
5316 scoped_ptr<SpdyFrame> 5320 scoped_ptr<SpdyFrame>
5317 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5321 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5318 scoped_ptr<SpdyFrame> 5322 scoped_ptr<SpdyFrame>
5319 stream1_body(ConstructSpdyBodyFrame(1, true)); 5323 stream1_body(ConstructSpdyBodyFrame(1, true));
5320 MockWrite writes[] = { 5324 MockWrite writes[] = {
5321 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), 5325 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS),
5322 }; 5326 };
5323 5327
5324 static const char* const kInitialHeaders[] = { 5328 static const char* const kInitialHeaders[] = {
5325 "url", 5329 ":scheme", "http",
5326 "http://www.google.com/foo.dat", 5330 ":host", "www.google.com",
5331 ":path", "/foo.dat"
5327 }; 5332 };
5328 static const char* const kLateHeaders[] = { 5333 static const char* const kLateHeaders[] = {
5329 "hello", 5334 "hello",
5330 "bye", 5335 "bye",
5331 "status", 5336 ":status",
5332 "200", 5337 "200",
5333 "version", 5338 ":version",
5334 "HTTP/1.1" 5339 "HTTP/1.1"
5335 }; 5340 };
5336 scoped_ptr<SpdyFrame> 5341 scoped_ptr<SpdyFrame>
5337 stream2_syn(ConstructSpdyControlFrame(kInitialHeaders, 5342 stream2_syn(ConstructSpdyControlFrame(kInitialHeaders,
5338 arraysize(kInitialHeaders) / 2, 5343 arraysize(kInitialHeaders) / 2,
5339 false, 5344 false,
5340 2, 5345 2,
5341 LOWEST, 5346 LOWEST,
5342 SYN_STREAM, 5347 SYN_STREAM,
5343 CONTROL_FLAG_NONE, 5348 CONTROL_FLAG_NONE,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
5452 }; 5457 };
5453 scoped_ptr<SpdyFrame> 5458 scoped_ptr<SpdyFrame>
5454 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5459 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5455 scoped_ptr<SpdyFrame> 5460 scoped_ptr<SpdyFrame>
5456 stream1_body(ConstructSpdyBodyFrame(1, true)); 5461 stream1_body(ConstructSpdyBodyFrame(1, true));
5457 MockWrite writes[] = { 5462 MockWrite writes[] = {
5458 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), 5463 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS),
5459 }; 5464 };
5460 5465
5461 static const char* const kInitialHeaders[] = { 5466 static const char* const kInitialHeaders[] = {
5462 "url", 5467 ":scheme", "http",
5463 "http://www.google.com/foo.dat", 5468 ":host", "www.google.com",
5469 ":path", "/foo.dat"
5464 }; 5470 };
5465 static const char* const kMiddleHeaders[] = { 5471 static const char* const kMiddleHeaders[] = {
5466 "hello", 5472 "hello",
5467 "bye", 5473 "bye",
5468 }; 5474 };
5469 static const char* const kLateHeaders[] = { 5475 static const char* const kLateHeaders[] = {
5470 "status", 5476 ":status",
5471 "200", 5477 "200",
5472 "version", 5478 ":version",
5473 "HTTP/1.1" 5479 "HTTP/1.1"
5474 }; 5480 };
5475 scoped_ptr<SpdyFrame> 5481 scoped_ptr<SpdyFrame>
5476 stream2_syn(ConstructSpdyControlFrame(kInitialHeaders, 5482 stream2_syn(ConstructSpdyControlFrame(kInitialHeaders,
5477 arraysize(kInitialHeaders) / 2, 5483 arraysize(kInitialHeaders) / 2,
5478 false, 5484 false,
5479 2, 5485 2,
5480 LOWEST, 5486 LOWEST,
5481 SYN_STREAM, 5487 SYN_STREAM,
5482 CONTROL_FLAG_NONE, 5488 CONTROL_FLAG_NONE,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
5588 // Verify the SYN_REPLY. 5594 // Verify the SYN_REPLY.
5589 EXPECT_TRUE(response.headers != NULL); 5595 EXPECT_TRUE(response.headers != NULL);
5590 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5596 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5591 5597
5592 // Verify the pushed stream. 5598 // Verify the pushed stream.
5593 EXPECT_TRUE(response2.headers != NULL); 5599 EXPECT_TRUE(response2.headers != NULL);
5594 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 5600 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
5595 5601
5596 // Verify we got all the headers 5602 // Verify we got all the headers
5597 EXPECT_TRUE(response2.headers->HasHeaderValue( 5603 EXPECT_TRUE(response2.headers->HasHeaderValue(
5598 "url", 5604 "scheme", "http"));
5599 "http://www.google.com/foo.dat")); 5605 EXPECT_TRUE(response2.headers->HasHeaderValue(
5606 "host", "www.google.com"));
5607 EXPECT_TRUE(response2.headers->HasHeaderValue(
5608 "path", "/foo.dat"));
5600 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); 5609 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye"));
5601 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); 5610 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200"));
5602 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1")); 5611 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1"));
5603 } 5612 }
5604 5613
5605 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithHeaders) { 5614 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithHeaders) {
5606 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5615 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5607 MockWrite writes[] = { CreateMockWrite(*req) }; 5616 MockWrite writes[] = { CreateMockWrite(*req) };
5608 5617
5609 static const char* const kInitialHeaders[] = { 5618 static const char* const kInitialHeaders[] = {
5610 "status", 5619 ":status",
5611 "200 OK", 5620 "200 OK",
5612 "version", 5621 ":version",
5613 "HTTP/1.1" 5622 "HTTP/1.1"
5614 }; 5623 };
5615 static const char* const kLateHeaders[] = { 5624 static const char* const kLateHeaders[] = {
5616 "hello", 5625 "hello",
5617 "bye", 5626 "bye",
5618 }; 5627 };
5619 scoped_ptr<SpdyFrame> 5628 scoped_ptr<SpdyFrame>
5620 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders, 5629 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders,
5621 arraysize(kInitialHeaders) / 2, 5630 arraysize(kInitialHeaders) / 2,
5622 false, 5631 false,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
5656 EXPECT_EQ(OK, out.rv); 5665 EXPECT_EQ(OK, out.rv);
5657 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 5666 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
5658 EXPECT_EQ("hello!", out.response_data); 5667 EXPECT_EQ("hello!", out.response_data);
5659 } 5668 }
5660 5669
5661 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithLateHeaders) { 5670 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithLateHeaders) {
5662 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5671 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5663 MockWrite writes[] = { CreateMockWrite(*req) }; 5672 MockWrite writes[] = { CreateMockWrite(*req) };
5664 5673
5665 static const char* const kInitialHeaders[] = { 5674 static const char* const kInitialHeaders[] = {
5666 "status", 5675 ":status",
5667 "200 OK", 5676 "200 OK",
5668 "version", 5677 ":version",
5669 "HTTP/1.1" 5678 "HTTP/1.1"
5670 }; 5679 };
5671 static const char* const kLateHeaders[] = { 5680 static const char* const kLateHeaders[] = {
5672 "hello", 5681 "hello",
5673 "bye", 5682 "bye",
5674 }; 5683 };
5675 scoped_ptr<SpdyFrame> 5684 scoped_ptr<SpdyFrame>
5676 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders, 5685 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders,
5677 arraysize(kInitialHeaders) / 2, 5686 arraysize(kInitialHeaders) / 2,
5678 false, 5687 false,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5714 EXPECT_EQ(OK, out.rv); 5723 EXPECT_EQ(OK, out.rv);
5715 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 5724 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
5716 EXPECT_EQ("hello!hello!", out.response_data); 5725 EXPECT_EQ("hello!hello!", out.response_data);
5717 } 5726 }
5718 5727
5719 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithDuplicateLateHeaders) { 5728 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithDuplicateLateHeaders) {
5720 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5729 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5721 MockWrite writes[] = { CreateMockWrite(*req) }; 5730 MockWrite writes[] = { CreateMockWrite(*req) };
5722 5731
5723 static const char* const kInitialHeaders[] = { 5732 static const char* const kInitialHeaders[] = {
5724 "status", 5733 ":status",
5725 "200 OK", 5734 "200 OK",
5726 "version", 5735 ":version",
5727 "HTTP/1.1" 5736 "HTTP/1.1"
5728 }; 5737 };
5729 static const char* const kLateHeaders[] = { 5738 static const char* const kLateHeaders[] = {
5730 "status", 5739 ":status",
5731 "500 Server Error", 5740 "500 Server Error",
5732 }; 5741 };
5733 scoped_ptr<SpdyFrame> 5742 scoped_ptr<SpdyFrame>
5734 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders, 5743 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders,
5735 arraysize(kInitialHeaders) / 2, 5744 arraysize(kInitialHeaders) / 2,
5736 false, 5745 false,
5737 1, 5746 1,
5738 LOWEST, 5747 LOWEST,
5739 SYN_REPLY, 5748 SYN_REPLY,
5740 CONTROL_FLAG_NONE, 5749 CONTROL_FLAG_NONE,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
5933 << " Write index: " 5942 << " Write index: "
5934 << data->write_index(); 5943 << data->write_index();
5935 5944
5936 // Verify the SYN_REPLY. 5945 // Verify the SYN_REPLY.
5937 HttpResponseInfo response = *trans->GetResponseInfo(); 5946 HttpResponseInfo response = *trans->GetResponseInfo();
5938 EXPECT_TRUE(response.headers != NULL); 5947 EXPECT_TRUE(response.headers != NULL);
5939 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5948 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5940 } 5949 }
5941 5950
5942 } // namespace net 5951 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698