1 // Copyright 2012 The Chromium Authors 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/test/embedded_test_server/http_response.h" 6 7 #include "testing/gtest/include/gtest/gtest.h" 8 9 namespace net::test_server { 10 TEST(HttpResponseTest,GenerateResponse)11TEST(HttpResponseTest, GenerateResponse) { 12 BasicHttpResponse response; 13 response.set_code(HTTP_OK); 14 response.set_content("Sample content - Hello world!"); 15 response.set_content_type("text/plain"); 16 response.AddCustomHeader("Simple-Header", "Simple value."); 17 18 std::string kExpectedResponseString = 19 "HTTP/1.1 200 OK\r\n" 20 "Connection: close\r\n" 21 "Content-Length: 29\r\n" 22 "Content-Type: text/plain\r\n" 23 "Simple-Header: Simple value.\r\n\r\n" 24 "Sample content - Hello world!"; 25 26 EXPECT_EQ(kExpectedResponseString, response.ToResponseString()); 27 } 28 29 } // namespace net::test_server 30