OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/callback_forward.h" | 7 #include "base/callback_forward.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 const std::string& cookie_header, | 35 const std::string& cookie_header, |
36 const std::string& response_body) { | 36 const std::string& response_body) { |
37 // We assume cookie_header ends with CRLF if not empty, as | 37 // We assume cookie_header ends with CRLF if not empty, as |
38 // WebSocketStandardRequestWithCookies requires. Use AddCRLFIfNotEmpty | 38 // WebSocketStandardRequestWithCookies requires. Use AddCRLFIfNotEmpty |
39 // in a call site. | 39 // in a call site. |
40 CHECK(cookie_header.empty() || | 40 CHECK(cookie_header.empty() || |
41 base::EndsWith(cookie_header, "\r\n", base::CompareCase::SENSITIVE)); | 41 base::EndsWith(cookie_header, "\r\n", base::CompareCase::SENSITIVE)); |
42 | 42 |
43 url_request_context_host_.SetExpectations( | 43 url_request_context_host_.SetExpectations( |
44 WebSocketStandardRequestWithCookies(url.path(), url.host(), origin, | 44 WebSocketStandardRequestWithCookies(url.path(), url.host(), origin, |
45 cookie_header, std::string()), | 45 cookie_header, std::string(), |
| 46 std::string()), |
46 response_body); | 47 response_body); |
47 CreateAndConnectStream(url.spec(), NoSubProtocols(), origin, nullptr); | 48 CreateAndConnectStream(url.spec(), NoSubProtocols(), origin, "", nullptr); |
48 } | 49 } |
49 | 50 |
50 std::string AddCRLFIfNotEmpty(const std::string& s) { | 51 std::string AddCRLFIfNotEmpty(const std::string& s) { |
51 return s.empty() ? s : s + "\r\n"; | 52 return s.empty() ? s : s + "\r\n"; |
52 } | 53 } |
53 }; | 54 }; |
54 | 55 |
55 struct ClientUseCookieParameter { | 56 struct ClientUseCookieParameter { |
56 // The URL for the WebSocket connection. | 57 // The URL for the WebSocket connection. |
57 const char* const url; | 58 const char* const url; |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 "", | 498 "", |
498 "Set-Cookie: test-cookie"}, | 499 "Set-Cookie: test-cookie"}, |
499 }; | 500 }; |
500 | 501 |
501 INSTANTIATE_TEST_CASE_P(WebSocketStreamServerSetCookieTest, | 502 INSTANTIATE_TEST_CASE_P(WebSocketStreamServerSetCookieTest, |
502 WebSocketStreamServerSetCookieTest, | 503 WebSocketStreamServerSetCookieTest, |
503 ValuesIn(kServerSetCookieParameters)); | 504 ValuesIn(kServerSetCookieParameters)); |
504 | 505 |
505 } // namespace | 506 } // namespace |
506 } // namespace net | 507 } // namespace net |
OLD | NEW |