OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/http/http_status_code.h" |
| 6 #include "net/server/http_server_response_info.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 |
| 9 namespace net { |
| 10 |
| 11 TEST(HttpServerResponseInfoTest, StatusLine) { |
| 12 HttpServerResponseInfo response; |
| 13 ASSERT_EQ("HTTP/1.1 200 OK\r\n\r\n", response.Serialize()); |
| 14 } |
| 15 |
| 16 TEST(HttpServerResponseInfoTest, Headers) { |
| 17 HttpServerResponseInfo response; |
| 18 response.AddHeader("A", "1"); |
| 19 response.AddHeader("A", "2"); |
| 20 ASSERT_EQ("HTTP/1.1 200 OK\r\nA:1\r\nA:2\r\n\r\n", response.Serialize()); |
| 21 } |
| 22 |
| 23 TEST(HttpServerResponseInfoTest, Body) { |
| 24 HttpServerResponseInfo response; |
| 25 response.SetBody("body", "type"); |
| 26 ASSERT_EQ( |
| 27 "HTTP/1.1 200 OK\r\nContent-Length:4\r\nContent-Type:type\r\n\r\nbody", |
| 28 response.Serialize()); |
| 29 } |
| 30 |
| 31 TEST(HttpServerResponseInfoTest, CreateFor404) { |
| 32 HttpServerResponseInfo response = HttpServerResponseInfo::CreateFor404(); |
| 33 ASSERT_EQ("HTTP/1.1 404 Not Found\r\nContent-Length:0\r\n\r\n", |
| 34 response.Serialize()); |
| 35 } |
| 36 |
| 37 TEST(HttpServerResponseInfoTest, CreateFor500) { |
| 38 HttpServerResponseInfo response = |
| 39 HttpServerResponseInfo::CreateFor500("mess"); |
| 40 ASSERT_EQ( |
| 41 "HTTP/1.1 500 Internal Server Error\r\n" |
| 42 "Content-Length:4\r\nContent-Type:text/html\r\n\r\nmess", |
| 43 response.Serialize()); |
| 44 } |
| 45 |
| 46 } // namespace net |
OLD | NEW |