summaryrefslogtreecommitdiff
path: root/chromium/net/test/embedded_test_server/http_response_unittest.cc
blob: 83b767f5fa8416ab3c02e0b473f5bd5f477b018e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/test/embedded_test_server/http_response.h"

#include "testing/gtest/include/gtest/gtest.h"

namespace net {
namespace test_server {

TEST(HttpResponseTest, GenerateResponse) {
  BasicHttpResponse response;
  response.set_code(HTTP_OK);
  response.set_content("Sample content - Hello world!");
  response.set_content_type("text/plain");
  response.AddCustomHeader("Simple-Header", "Simple value.");

  std::string kExpectedResponseString =
      "HTTP/1.1 200 OK\r\n"
      "Connection: close\r\n"
      "Content-Length: 29\r\n"
      "Content-Type: text/plain\r\n"
      "Simple-Header: Simple value.\r\n\r\n"
      "Sample content - Hello world!";

  EXPECT_EQ(kExpectedResponseString, response.ToResponseString());
}

}  // namespace test_server
}  // namespace net