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

Side by Side Diff: net/test/embedded_test_server/request_helpers.h

Issue 1376593007: SSL in EmbeddedTestServer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing unused macros. Created 5 years, 2 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
OLDNEW
(Empty)
1 // Copyright 2015 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 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_REQUEST_HELPERS_H_
6 #define NET_TEST_EMBEDDED_TEST_SERVER_REQUEST_HELPERS_H_
7
8 #include <utility>
9
10 #include "base/files/file_path.h"
11 #include "base/strings/string_split.h"
12 #include "net/test/embedded_test_server/embedded_test_server.h"
13 #include "net/test/embedded_test_server/http_request.h"
14 #include "net/test/embedded_test_server/http_response.h"
15 #include "url/gurl.h"
16
17 namespace net {
18 namespace test_server {
19
20 // This file is only meant for compatibility with testserver.py. No
21 // additional handlers should be added here that don't affect multiple
22 // distinct tests.
23
24 using RequestQuery = std::map<std::string, std::vector<std::string>>;
25
26 class CustomHttpResponse : public HttpResponse {
27 public:
28 CustomHttpResponse(const std::string& headers, const std::string& contents)
29 : headers_(headers), contents_(contents) {}
mmenke 2015/10/19 18:07:41 nit: De-inline the constructor.
mmenke 2015/10/19 18:07:41 Child classes should have a destructor with overri
svaldez 2015/10/19 21:56:15 Done.
svaldez 2015/10/19 21:56:15 Done.
30
31 void SendResponse(SendBytesCallback send, SendCompleteCallback done) override;
32
33 private:
34 std::string headers_;
35 std::string contents_;
mmenke 2015/10/19 18:07:41 Make these const?
svaldez 2015/10/19 21:56:15 Done.
36
37 DISALLOW_COPY_AND_ASSIGN(CustomHttpResponse);
38 };
39
40 // Return whether |request| starts with a URL path of |url|.
41 bool ShouldHandle(const HttpRequest& request, std::string prefix_path);
42
43 // Calls |handler| if the |request| URL starts with |prefix|.
44 scoped_ptr<HttpResponse> HandlePrefixedRequest(
45 std::string prefix,
mmenke 2015/10/19 18:07:41 const std::string&
svaldez 2015/10/19 21:56:15 Done.
46 EmbeddedTestServer::HandleRequestCallback handler,
mmenke 2015/10/19 18:07:41 const EmbeddedTestServer::HandleRequestCallback&
svaldez 2015/10/19 21:56:15 Done.
47 const HttpRequest& request);
48
49 // Parses |data| as the query of a URL and places it into a map.
mmenke 2015/10/19 18:07:41 This comment needs to be updated (There is no |dat
svaldez 2015/10/19 21:56:15 Done.
50 RequestQuery ParseQuery(const GURL& url);
51
52 // Returns a path that serves |original_path| with text that matches
53 // |text_to_replace| with the corresponding values, and then returns the
54 // resulting path in |replacement_path|.
55 void GetFilePathWithReplacements(const std::string& original_path,
56 const base::StringPairs& text_to_replace,
57 std::string* replacement_path);
mmenke 2015/10/19 18:07:41 Maybe make this a method on the test server? GURL
svaldez 2015/10/19 21:56:15 This should probably be bound to HandleFileRequest
58
59 // Handles |request| by serving a file from under |server_root|.
60 scoped_ptr<HttpResponse> HandleFileRequest(const base::FilePath& server_root,
61 const HttpRequest& request);
62
63 } // namespace test_server
64 } // namespace net
65
66 #endif // NET_TEST_EMBEDDED_TEST_SERVER_REQUEST_HELPERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698