| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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, |
| 2709 2, 1)); |
| 2706 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 2710 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 2707 MockRead reads[] = { | 2711 MockRead reads[] = { |
| 2708 CreateMockRead(*reply, 1), | 2712 CreateMockRead(*reply, 1), |
| 2709 CreateMockRead(*push, 1), | 2713 CreateMockRead(*push, 1), |
| 2710 CreateMockRead(*body, 1), | 2714 CreateMockRead(*body, 1), |
| 2711 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause | 2715 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause |
| 2712 }; | 2716 }; |
| 2713 | 2717 |
| 2714 HttpResponseInfo response; | 2718 HttpResponseInfo response; |
| 2715 HttpResponseInfo response2; | 2719 HttpResponseInfo response2; |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3466 int num_headers; | 3470 int num_headers; |
| 3467 const char* extra_headers[5]; | 3471 const char* extra_headers[5]; |
| 3468 const char* expected_headers; | 3472 const char* expected_headers; |
| 3469 } test_cases[] = { | 3473 } test_cases[] = { |
| 3470 // This uses a multi-valued cookie header. | 3474 // This uses a multi-valued cookie header. |
| 3471 { 2, | 3475 { 2, |
| 3472 { "cookie", "val1", | 3476 { "cookie", "val1", |
| 3473 "cookie", "val2", // will get appended separated by NULL | 3477 "cookie", "val2", // will get appended separated by NULL |
| 3474 NULL | 3478 NULL |
| 3475 }, | 3479 }, |
| 3480 "status: 200\n" |
| 3481 "version: HTTP/1.1\n" |
| 3476 "cookie: val1\n" | 3482 "cookie: val1\n" |
| 3477 "cookie: val2\n" | 3483 "cookie: val2\n" |
| 3478 "hello: bye\n" | 3484 "hello: bye\n" |
| 3479 "status: 200\n" | |
| 3480 "version: HTTP/1.1\n" | |
| 3481 }, | 3485 }, |
| 3482 // This is the minimalist set of headers. | 3486 // This is the minimalist set of headers. |
| 3483 { 0, | 3487 { 0, |
| 3484 { NULL }, | 3488 { NULL }, |
| 3485 "hello: bye\n" | |
| 3486 "status: 200\n" | 3489 "status: 200\n" |
| 3487 "version: HTTP/1.1\n" | 3490 "version: HTTP/1.1\n" |
| 3491 "hello: bye\n" |
| 3488 }, | 3492 }, |
| 3489 // Headers with a comma separated list. | 3493 // Headers with a comma separated list. |
| 3490 { 1, | 3494 { 1, |
| 3491 { "cookie", "val1,val2", | 3495 { "cookie", "val1,val2", |
| 3492 NULL | 3496 NULL |
| 3493 }, | 3497 }, |
| 3498 "status: 200\n" |
| 3499 "version: HTTP/1.1\n" |
| 3494 "cookie: val1,val2\n" | 3500 "cookie: val1,val2\n" |
| 3495 "hello: bye\n" | 3501 "hello: bye\n" |
| 3496 "status: 200\n" | |
| 3497 "version: HTTP/1.1\n" | |
| 3498 } | 3502 } |
| 3499 }; | 3503 }; |
| 3500 | 3504 |
| 3501 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 3505 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
| 3502 scoped_ptr<SpdyFrame> req( | 3506 scoped_ptr<SpdyFrame> req( |
| 3503 ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3507 ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 3504 MockWrite writes[] = { CreateMockWrite(*req) }; | 3508 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 3505 | 3509 |
| 3506 scoped_ptr<SpdyFrame> resp( | 3510 scoped_ptr<SpdyFrame> resp( |
| 3507 ConstructSpdyGetSynReply(test_cases[i].extra_headers, | 3511 ConstructSpdyGetSynReply(test_cases[i].extra_headers, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3565 } test_cases[] = { | 3569 } test_cases[] = { |
| 3566 // Test the case of a multi-valued cookie. When the value is delimited | 3570 // 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. | 3571 // with NUL characters, it needs to be unfolded into multiple headers. |
| 3568 { | 3572 { |
| 3569 &syn_reply_info, | 3573 &syn_reply_info, |
| 3570 true, | 3574 true, |
| 3571 { 1, 4 }, | 3575 { 1, 4 }, |
| 3572 { { "cookie", "val1,val2", | 3576 { { "cookie", "val1,val2", |
| 3573 NULL | 3577 NULL |
| 3574 }, | 3578 }, |
| 3575 { "vary", "cookie", | 3579 { ":status", "200", |
| 3576 "status", "200", | 3580 ":version", "HTTP/1.1", |
| 3581 "vary", "cookie", |
| 3577 "url", "/index.php", | 3582 "url", "/index.php", |
| 3578 "version", "HTTP/1.1", | |
| 3579 NULL | 3583 NULL |
| 3580 } | 3584 } |
| 3581 } | 3585 } |
| 3582 }, { // Multiple vary fields. | 3586 }, { // Multiple vary fields. |
| 3583 &syn_reply_info, | 3587 &syn_reply_info, |
| 3584 true, | 3588 true, |
| 3585 { 2, 5 }, | 3589 { 2, 5 }, |
| 3586 { { "friend", "barney", | 3590 { { "friend", "barney", |
| 3587 "enemy", "snaggletooth", | 3591 "enemy", "snaggletooth", |
| 3588 NULL | 3592 NULL |
| 3589 }, | 3593 }, |
| 3590 { "vary", "friend", | 3594 { ":status", "200", |
| 3595 ":version", "HTTP/1.1", |
| 3596 "vary", "friend", |
| 3591 "vary", "enemy", | 3597 "vary", "enemy", |
| 3592 "status", "200", | |
| 3593 "url", "/index.php", | 3598 "url", "/index.php", |
| 3594 "version", "HTTP/1.1", | |
| 3595 NULL | 3599 NULL |
| 3596 } | 3600 } |
| 3597 } | 3601 } |
| 3598 }, { // Test a '*' vary field. | 3602 }, { // Test a '*' vary field. |
| 3599 &syn_reply_info, | 3603 &syn_reply_info, |
| 3600 false, | 3604 false, |
| 3601 { 1, 4 }, | 3605 { 1, 4 }, |
| 3602 { { "cookie", "val1,val2", | 3606 { { "cookie", "val1,val2", |
| 3603 NULL | 3607 NULL |
| 3604 }, | 3608 }, |
| 3605 { "vary", "*", | 3609 { ":status", "200", |
| 3606 "status", "200", | 3610 ":version", "HTTP/1.1", |
| 3611 "vary", "*", |
| 3607 "url", "/index.php", | 3612 "url", "/index.php", |
| 3608 "version", "HTTP/1.1", | |
| 3609 NULL | 3613 NULL |
| 3610 } | 3614 } |
| 3611 } | 3615 } |
| 3612 }, { // Multiple comma-separated vary fields. | 3616 }, { // Multiple comma-separated vary fields. |
| 3613 &syn_reply_info, | 3617 &syn_reply_info, |
| 3614 true, | 3618 true, |
| 3615 { 2, 4 }, | 3619 { 2, 4 }, |
| 3616 { { "friend", "barney", | 3620 { { "friend", "barney", |
| 3617 "enemy", "snaggletooth", | 3621 "enemy", "snaggletooth", |
| 3618 NULL | 3622 NULL |
| 3619 }, | 3623 }, |
| 3620 { "vary", "friend,enemy", | 3624 { ":status", "200", |
| 3621 "status", "200", | 3625 ":version", "HTTP/1.1", |
| 3626 "vary", "friend,enemy", |
| 3622 "url", "/index.php", | 3627 "url", "/index.php", |
| 3623 "version", "HTTP/1.1", | |
| 3624 NULL | 3628 NULL |
| 3625 } | 3629 } |
| 3626 } | 3630 } |
| 3627 } | 3631 } |
| 3628 }; | 3632 }; |
| 3629 | 3633 |
| 3630 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 3634 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
| 3631 // Construct the request. | 3635 // Construct the request. |
| 3632 scoped_ptr<SpdyFrame> frame_req( | 3636 scoped_ptr<SpdyFrame> frame_req( |
| 3633 ConstructSpdyGet(test_cases[i].extra_headers[0], | 3637 ConstructSpdyGet(test_cases[i].extra_headers[0], |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3734 { 4, | 3738 { 4, |
| 3735 { "cookie", "val1", | 3739 { "cookie", "val1", |
| 3736 "cookie", "val2", | 3740 "cookie", "val2", |
| 3737 "url", "/index.php", | 3741 "url", "/index.php", |
| 3738 "version", "HTTP/1.1", | 3742 "version", "HTTP/1.1", |
| 3739 NULL | 3743 NULL |
| 3740 }, | 3744 }, |
| 3741 }, | 3745 }, |
| 3742 // SYN_REPLY missing version header | 3746 // SYN_REPLY missing version header |
| 3743 { 2, | 3747 { 2, |
| 3744 { "status", "200", | 3748 { ":status", "200", |
| 3745 "url", "/index.php", | 3749 "url", "/index.php", |
| 3746 NULL | 3750 NULL |
| 3747 }, | 3751 }, |
| 3748 }, | 3752 }, |
| 3749 // SYN_REPLY with no headers | 3753 // SYN_REPLY with no headers |
| 3750 { 0, { NULL }, }, | 3754 { 0, { NULL }, }, |
| 3751 }; | 3755 }; |
| 3752 | 3756 |
| 3753 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 3757 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
| 3754 scoped_ptr<SpdyFrame> req( | 3758 scoped_ptr<SpdyFrame> req( |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4440 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority | 4444 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority |
| 4441 0, // Credential Slot | 4445 0, // Credential Slot |
| 4442 CONTROL_FLAG_NONE, // Control Flags | 4446 CONTROL_FLAG_NONE, // Control Flags |
| 4443 false, // Compressed | 4447 false, // Compressed |
| 4444 INVALID, // Status | 4448 INVALID, // Status |
| 4445 NULL, // Data | 4449 NULL, // Data |
| 4446 0, // Data Length | 4450 0, // Data Length |
| 4447 DATA_FLAG_NONE // Data Flags | 4451 DATA_FLAG_NONE // Data Flags |
| 4448 }; | 4452 }; |
| 4449 static const char* const kExtraHeaders[] = { | 4453 static const char* const kExtraHeaders[] = { |
| 4450 "status", "200", | 4454 ":status", "200", |
| 4451 "version", "HTTP/1.1" | 4455 ":version", "HTTP/1.1" |
| 4452 }; | 4456 }; |
| 4453 | 4457 |
| 4454 BoundNetLog net_log; | 4458 BoundNetLog net_log; |
| 4455 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam()); | 4459 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam()); |
| 4456 helper.RunPreTestSetup(); | 4460 helper.RunPreTestSetup(); |
| 4457 | 4461 |
| 4458 // Verify that no settings exist initially. | 4462 // Verify that no settings exist initially. |
| 4459 HostPortPair host_port_pair("www.google.com", helper.port()); | 4463 HostPortPair host_port_pair("www.google.com", helper.port()); |
| 4460 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 4464 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
| 4461 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( | 4465 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4547 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority | 4551 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority |
| 4548 0, // Credential Slot | 4552 0, // Credential Slot |
| 4549 CONTROL_FLAG_NONE, // Control Flags | 4553 CONTROL_FLAG_NONE, // Control Flags |
| 4550 false, // Compressed | 4554 false, // Compressed |
| 4551 INVALID, // Status | 4555 INVALID, // Status |
| 4552 NULL, // Data | 4556 NULL, // Data |
| 4553 0, // Data Length | 4557 0, // Data Length |
| 4554 DATA_FLAG_NONE // Data Flags | 4558 DATA_FLAG_NONE // Data Flags |
| 4555 }; | 4559 }; |
| 4556 static const char* kExtraHeaders[] = { | 4560 static const char* kExtraHeaders[] = { |
| 4557 "status", "200", | 4561 ":status", "200", |
| 4558 "version", "HTTP/1.1" | 4562 ":version", "HTTP/1.1" |
| 4559 }; | 4563 }; |
| 4560 | 4564 |
| 4561 BoundNetLog net_log; | 4565 BoundNetLog net_log; |
| 4562 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam()); | 4566 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam()); |
| 4563 helper.RunPreTestSetup(); | 4567 helper.RunPreTestSetup(); |
| 4564 | 4568 |
| 4565 // Verify that no settings exist initially. | 4569 // Verify that no settings exist initially. |
| 4566 HostPortPair host_port_pair("www.google.com", helper.port()); | 4570 HostPortPair host_port_pair("www.google.com", helper.port()); |
| 4567 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 4571 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
| 4568 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( | 4572 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5231 }; | 5235 }; |
| 5232 scoped_ptr<SpdyFrame> | 5236 scoped_ptr<SpdyFrame> |
| 5233 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5237 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 5234 scoped_ptr<SpdyFrame> | 5238 scoped_ptr<SpdyFrame> |
| 5235 stream1_body(ConstructSpdyBodyFrame(1, true)); | 5239 stream1_body(ConstructSpdyBodyFrame(1, true)); |
| 5236 MockWrite writes[] = { | 5240 MockWrite writes[] = { |
| 5237 CreateMockWrite(*stream1_syn, 1), | 5241 CreateMockWrite(*stream1_syn, 1), |
| 5238 }; | 5242 }; |
| 5239 | 5243 |
| 5240 static const char* const kInitialHeaders[] = { | 5244 static const char* const kInitialHeaders[] = { |
| 5241 "url", | 5245 ":scheme", "http", |
| 5242 "http://www.google.com/foo.dat", | 5246 ":host", "www.google.com", |
| 5247 ":path", "/foo.dat", |
| 5243 }; | 5248 }; |
| 5244 static const char* const kLateHeaders[] = { | 5249 static const char* const kLateHeaders[] = { |
| 5245 "hello", | 5250 "hello", |
| 5246 "bye", | 5251 "bye", |
| 5247 "status", | 5252 ":status", |
| 5248 "200", | 5253 "200", |
| 5249 "version", | 5254 ":version", |
| 5250 "HTTP/1.1" | 5255 "HTTP/1.1" |
| 5251 }; | 5256 }; |
| 5252 scoped_ptr<SpdyFrame> | 5257 scoped_ptr<SpdyFrame> |
| 5253 stream2_syn(ConstructSpdyControlFrame(kInitialHeaders, | 5258 stream2_syn(ConstructSpdyControlFrame(kInitialHeaders, |
| 5254 arraysize(kInitialHeaders) / 2, | 5259 arraysize(kInitialHeaders) / 2, |
| 5255 false, | 5260 false, |
| 5256 2, | 5261 2, |
| 5257 LOWEST, | 5262 LOWEST, |
| 5258 SYN_STREAM, | 5263 SYN_STREAM, |
| 5259 CONTROL_FLAG_NONE, | 5264 CONTROL_FLAG_NONE, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5315 }; | 5320 }; |
| 5316 scoped_ptr<SpdyFrame> | 5321 scoped_ptr<SpdyFrame> |
| 5317 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5322 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 5318 scoped_ptr<SpdyFrame> | 5323 scoped_ptr<SpdyFrame> |
| 5319 stream1_body(ConstructSpdyBodyFrame(1, true)); | 5324 stream1_body(ConstructSpdyBodyFrame(1, true)); |
| 5320 MockWrite writes[] = { | 5325 MockWrite writes[] = { |
| 5321 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), | 5326 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), |
| 5322 }; | 5327 }; |
| 5323 | 5328 |
| 5324 static const char* const kInitialHeaders[] = { | 5329 static const char* const kInitialHeaders[] = { |
| 5325 "url", | 5330 ":scheme", "http", |
| 5326 "http://www.google.com/foo.dat", | 5331 ":host", "www.google.com", |
| 5332 ":path", "/foo.dat" |
| 5327 }; | 5333 }; |
| 5328 static const char* const kLateHeaders[] = { | 5334 static const char* const kLateHeaders[] = { |
| 5329 "hello", | 5335 "hello", |
| 5330 "bye", | 5336 "bye", |
| 5331 "status", | 5337 ":status", |
| 5332 "200", | 5338 "200", |
| 5333 "version", | 5339 ":version", |
| 5334 "HTTP/1.1" | 5340 "HTTP/1.1" |
| 5335 }; | 5341 }; |
| 5336 scoped_ptr<SpdyFrame> | 5342 scoped_ptr<SpdyFrame> |
| 5337 stream2_syn(ConstructSpdyControlFrame(kInitialHeaders, | 5343 stream2_syn(ConstructSpdyControlFrame(kInitialHeaders, |
| 5338 arraysize(kInitialHeaders) / 2, | 5344 arraysize(kInitialHeaders) / 2, |
| 5339 false, | 5345 false, |
| 5340 2, | 5346 2, |
| 5341 LOWEST, | 5347 LOWEST, |
| 5342 SYN_STREAM, | 5348 SYN_STREAM, |
| 5343 CONTROL_FLAG_NONE, | 5349 CONTROL_FLAG_NONE, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5452 }; | 5458 }; |
| 5453 scoped_ptr<SpdyFrame> | 5459 scoped_ptr<SpdyFrame> |
| 5454 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5460 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 5455 scoped_ptr<SpdyFrame> | 5461 scoped_ptr<SpdyFrame> |
| 5456 stream1_body(ConstructSpdyBodyFrame(1, true)); | 5462 stream1_body(ConstructSpdyBodyFrame(1, true)); |
| 5457 MockWrite writes[] = { | 5463 MockWrite writes[] = { |
| 5458 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), | 5464 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), |
| 5459 }; | 5465 }; |
| 5460 | 5466 |
| 5461 static const char* const kInitialHeaders[] = { | 5467 static const char* const kInitialHeaders[] = { |
| 5462 "url", | 5468 ":scheme", "http", |
| 5463 "http://www.google.com/foo.dat", | 5469 ":host", "www.google.com", |
| 5470 ":path", "/foo.dat" |
| 5464 }; | 5471 }; |
| 5465 static const char* const kMiddleHeaders[] = { | 5472 static const char* const kMiddleHeaders[] = { |
| 5466 "hello", | 5473 "hello", |
| 5467 "bye", | 5474 "bye", |
| 5468 }; | 5475 }; |
| 5469 static const char* const kLateHeaders[] = { | 5476 static const char* const kLateHeaders[] = { |
| 5470 "status", | 5477 ":status", |
| 5471 "200", | 5478 "200", |
| 5472 "version", | 5479 ":version", |
| 5473 "HTTP/1.1" | 5480 "HTTP/1.1" |
| 5474 }; | 5481 }; |
| 5475 scoped_ptr<SpdyFrame> | 5482 scoped_ptr<SpdyFrame> |
| 5476 stream2_syn(ConstructSpdyControlFrame(kInitialHeaders, | 5483 stream2_syn(ConstructSpdyControlFrame(kInitialHeaders, |
| 5477 arraysize(kInitialHeaders) / 2, | 5484 arraysize(kInitialHeaders) / 2, |
| 5478 false, | 5485 false, |
| 5479 2, | 5486 2, |
| 5480 LOWEST, | 5487 LOWEST, |
| 5481 SYN_STREAM, | 5488 SYN_STREAM, |
| 5482 CONTROL_FLAG_NONE, | 5489 CONTROL_FLAG_NONE, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5588 // Verify the SYN_REPLY. | 5595 // Verify the SYN_REPLY. |
| 5589 EXPECT_TRUE(response.headers != NULL); | 5596 EXPECT_TRUE(response.headers != NULL); |
| 5590 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5597 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 5591 | 5598 |
| 5592 // Verify the pushed stream. | 5599 // Verify the pushed stream. |
| 5593 EXPECT_TRUE(response2.headers != NULL); | 5600 EXPECT_TRUE(response2.headers != NULL); |
| 5594 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 5601 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 5595 | 5602 |
| 5596 // Verify we got all the headers | 5603 // Verify we got all the headers |
| 5597 EXPECT_TRUE(response2.headers->HasHeaderValue( | 5604 EXPECT_TRUE(response2.headers->HasHeaderValue( |
| 5598 "url", | 5605 "scheme", "http")); |
| 5599 "http://www.google.com/foo.dat")); | 5606 EXPECT_TRUE(response2.headers->HasHeaderValue( |
| 5607 "host", "www.google.com")); |
| 5608 EXPECT_TRUE(response2.headers->HasHeaderValue( |
| 5609 "path", "/foo.dat")); |
| 5600 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); | 5610 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); |
| 5601 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); | 5611 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); |
| 5602 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1")); | 5612 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1")); |
| 5603 } | 5613 } |
| 5604 | 5614 |
| 5605 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithHeaders) { | 5615 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithHeaders) { |
| 5606 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5616 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 5607 MockWrite writes[] = { CreateMockWrite(*req) }; | 5617 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 5608 | 5618 |
| 5609 static const char* const kInitialHeaders[] = { | 5619 static const char* const kInitialHeaders[] = { |
| 5610 "status", | 5620 ":status", |
| 5611 "200 OK", | 5621 "200 OK", |
| 5612 "version", | 5622 ":version", |
| 5613 "HTTP/1.1" | 5623 "HTTP/1.1" |
| 5614 }; | 5624 }; |
| 5615 static const char* const kLateHeaders[] = { | 5625 static const char* const kLateHeaders[] = { |
| 5616 "hello", | 5626 "hello", |
| 5617 "bye", | 5627 "bye", |
| 5618 }; | 5628 }; |
| 5619 scoped_ptr<SpdyFrame> | 5629 scoped_ptr<SpdyFrame> |
| 5620 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders, | 5630 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders, |
| 5621 arraysize(kInitialHeaders) / 2, | 5631 arraysize(kInitialHeaders) / 2, |
| 5622 false, | 5632 false, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5656 EXPECT_EQ(OK, out.rv); | 5666 EXPECT_EQ(OK, out.rv); |
| 5657 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 5667 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 5658 EXPECT_EQ("hello!", out.response_data); | 5668 EXPECT_EQ("hello!", out.response_data); |
| 5659 } | 5669 } |
| 5660 | 5670 |
| 5661 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithLateHeaders) { | 5671 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithLateHeaders) { |
| 5662 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5672 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 5663 MockWrite writes[] = { CreateMockWrite(*req) }; | 5673 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 5664 | 5674 |
| 5665 static const char* const kInitialHeaders[] = { | 5675 static const char* const kInitialHeaders[] = { |
| 5666 "status", | 5676 ":status", |
| 5667 "200 OK", | 5677 "200 OK", |
| 5668 "version", | 5678 ":version", |
| 5669 "HTTP/1.1" | 5679 "HTTP/1.1" |
| 5670 }; | 5680 }; |
| 5671 static const char* const kLateHeaders[] = { | 5681 static const char* const kLateHeaders[] = { |
| 5672 "hello", | 5682 "hello", |
| 5673 "bye", | 5683 "bye", |
| 5674 }; | 5684 }; |
| 5675 scoped_ptr<SpdyFrame> | 5685 scoped_ptr<SpdyFrame> |
| 5676 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders, | 5686 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders, |
| 5677 arraysize(kInitialHeaders) / 2, | 5687 arraysize(kInitialHeaders) / 2, |
| 5678 false, | 5688 false, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5714 EXPECT_EQ(OK, out.rv); | 5724 EXPECT_EQ(OK, out.rv); |
| 5715 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 5725 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 5716 EXPECT_EQ("hello!hello!", out.response_data); | 5726 EXPECT_EQ("hello!hello!", out.response_data); |
| 5717 } | 5727 } |
| 5718 | 5728 |
| 5719 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithDuplicateLateHeaders) { | 5729 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithDuplicateLateHeaders) { |
| 5720 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5730 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 5721 MockWrite writes[] = { CreateMockWrite(*req) }; | 5731 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 5722 | 5732 |
| 5723 static const char* const kInitialHeaders[] = { | 5733 static const char* const kInitialHeaders[] = { |
| 5724 "status", | 5734 ":status", |
| 5725 "200 OK", | 5735 "200 OK", |
| 5726 "version", | 5736 ":version", |
| 5727 "HTTP/1.1" | 5737 "HTTP/1.1" |
| 5728 }; | 5738 }; |
| 5729 static const char* const kLateHeaders[] = { | 5739 static const char* const kLateHeaders[] = { |
| 5730 "status", | 5740 ":status", |
| 5731 "500 Server Error", | 5741 "500 Server Error", |
| 5732 }; | 5742 }; |
| 5733 scoped_ptr<SpdyFrame> | 5743 scoped_ptr<SpdyFrame> |
| 5734 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders, | 5744 stream1_reply(ConstructSpdyControlFrame(kInitialHeaders, |
| 5735 arraysize(kInitialHeaders) / 2, | 5745 arraysize(kInitialHeaders) / 2, |
| 5736 false, | 5746 false, |
| 5737 1, | 5747 1, |
| 5738 LOWEST, | 5748 LOWEST, |
| 5739 SYN_REPLY, | 5749 SYN_REPLY, |
| 5740 CONTROL_FLAG_NONE, | 5750 CONTROL_FLAG_NONE, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5938 << " Write index: " | 5948 << " Write index: " |
| 5939 << data->write_index(); | 5949 << data->write_index(); |
| 5940 | 5950 |
| 5941 // Verify the SYN_REPLY. | 5951 // Verify the SYN_REPLY. |
| 5942 HttpResponseInfo response = *trans->GetResponseInfo(); | 5952 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 5943 EXPECT_TRUE(response.headers != NULL); | 5953 EXPECT_TRUE(response.headers != NULL); |
| 5944 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5954 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 5945 } | 5955 } |
| 5946 | 5956 |
| 5947 } // namespace net | 5957 } // namespace net |
| OLD | NEW |