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/test/embedded_test_server/http_request.h" | 5 #include "net/test/embedded_test_server/http_request.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace google_apis { | 9 namespace net { |
10 namespace test_server { | 10 namespace test_server { |
11 | 11 |
12 TEST(HttpRequestTest, ParseRequest) { | 12 TEST(HttpRequestTest, ParseRequest) { |
13 HttpRequestParser parser; | 13 HttpRequestParser parser; |
14 | 14 |
15 // Process request in chunks to check if the parser deals with border cases. | 15 // Process request in chunks to check if the parser deals with border cases. |
16 // Also, check multi-line headers as well as multiple requests in the same | 16 // Also, check multi-line headers as well as multiple requests in the same |
17 // chunk. This basically should cover all the simplest border cases. | 17 // chunk. This basically should cover all the simplest border cases. |
18 parser.ProcessChunk("POST /foobar.html HTTP/1.1\r\n"); | 18 parser.ProcessChunk("POST /foobar.html HTTP/1.1\r\n"); |
19 EXPECT_EQ(HttpRequestParser::WAITING, parser.ParseRequest()); | 19 EXPECT_EQ(HttpRequestParser::WAITING, parser.ParseRequest()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 parser.ProcessChunk("POST /foobar.html HTTP/1.1\r\n\r\n"); | 73 parser.ProcessChunk("POST /foobar.html HTTP/1.1\r\n\r\n"); |
74 ASSERT_EQ(HttpRequestParser::ACCEPTED, parser.ParseRequest()); | 74 ASSERT_EQ(HttpRequestParser::ACCEPTED, parser.ParseRequest()); |
75 | 75 |
76 scoped_ptr<HttpRequest> request = parser.GetRequest(); | 76 scoped_ptr<HttpRequest> request = parser.GetRequest(); |
77 EXPECT_EQ("", request->content); | 77 EXPECT_EQ("", request->content); |
78 EXPECT_FALSE(request->has_content); | 78 EXPECT_FALSE(request->has_content); |
79 } | 79 } |
80 | 80 |
81 } // namespace test_server | 81 } // namespace test_server |
82 } // namespace google_apis | 82 } // namespace net |
OLD | NEW |