Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: net/server/http_server_response_info_unittest.cc

Issue 19637005: Allow HttpServer response to include custom headers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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, NotFound) {
32 HttpServerResponseInfo response = HttpServerResponseInfo::For404();
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, For500) {
38 HttpServerResponseInfo response = HttpServerResponseInfo::For500("mess");
39 ASSERT_EQ(
40 "HTTP/1.1 500 Internal Server Error\r\n"
41 "Content-Length:4\r\nContent-Type:text/html\r\n\r\nmess",
42 response.Serialize());
43 }
44
45 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698