| 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/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 class TestBase : public WebSocketStreamCreateTestBase { | 29 class TestBase : public WebSocketStreamCreateTestBase { |
| 30 public: | 30 public: |
| 31 void CreateAndConnect(const GURL& url, | 31 void CreateAndConnect(const GURL& url, |
| 32 const std::string& origin, | 32 const std::string& origin, |
| 33 const std::string& cookie_header, | 33 const std::string& cookie_header, |
| 34 const std::string& response_body) { | 34 const std::string& response_body) { |
| 35 // We assume cookie_header ends with CRLF if not empty, as | 35 // We assume cookie_header ends with CRLF if not empty, as |
| 36 // WebSocketStandardRequestWithCookies requires. Use AddCRLFIfNotEmpty | 36 // WebSocketStandardRequestWithCookies requires. Use AddCRLFIfNotEmpty |
| 37 // in a call site. | 37 // in a call site. |
| 38 CHECK(cookie_header.empty() || EndsWith(cookie_header, "\r\n", true)); | 38 CHECK(cookie_header.empty() || base::EndsWith(cookie_header, "\r\n", true)); |
| 39 | 39 |
| 40 url_request_context_host_.SetExpectations( | 40 url_request_context_host_.SetExpectations( |
| 41 WebSocketStandardRequestWithCookies(url.path(), url.host(), origin, | 41 WebSocketStandardRequestWithCookies(url.path(), url.host(), origin, |
| 42 cookie_header, std::string()), | 42 cookie_header, std::string()), |
| 43 response_body); | 43 response_body); |
| 44 CreateAndConnectStream(url.spec(), NoSubProtocols(), origin, nullptr); | 44 CreateAndConnectStream(url.spec(), NoSubProtocols(), origin, nullptr); |
| 45 } | 45 } |
| 46 | 46 |
| 47 std::string AddCRLFIfNotEmpty(const std::string& s) { | 47 std::string AddCRLFIfNotEmpty(const std::string& s) { |
| 48 return s.empty() ? s : s + "\r\n"; | 48 return s.empty() ? s : s + "\r\n"; |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 "", | 494 "", |
| 495 "Set-Cookie: test-cookie"}, | 495 "Set-Cookie: test-cookie"}, |
| 496 }; | 496 }; |
| 497 | 497 |
| 498 INSTANTIATE_TEST_CASE_P(WebSocketStreamServerSetCookieTest, | 498 INSTANTIATE_TEST_CASE_P(WebSocketStreamServerSetCookieTest, |
| 499 WebSocketStreamServerSetCookieTest, | 499 WebSocketStreamServerSetCookieTest, |
| 500 ValuesIn(kServerSetCookieParameters)); | 500 ValuesIn(kServerSetCookieParameters)); |
| 501 | 501 |
| 502 } // namespace | 502 } // namespace |
| 503 } // namespace net | 503 } // namespace net |
| OLD | NEW |