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

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: Rebase. 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 class CustomHttpResponse : public HttpResponse {
25 public:
26 CustomHttpResponse(const std::string& headers, const std::string& contents)
27 : headers_(headers), contents_(contents) {}
28
29 void SendResponse(SendCallback send, SendDoneCallback done) override;
30
31 private:
32 std::string headers_;
33 std::string contents_;
34
35 DISALLOW_COPY_AND_ASSIGN(CustomHttpResponse);
36 };
37
38 typedef std::map<std::string, std::vector<std::string>> RequestQuery;
39
40 // Parses |data| as the query of a URL and places it into a map.
41 RequestQuery ParseQuery(GURL url);
42
43 // Handles |request| by serving a file from under |server_root|.
44 scoped_ptr<HttpResponse> HandleFileRequest(const base::FilePath& server_root,
45 const HttpRequest& request);
46
47 // Registers default handlers for use in tests.
48 void RegisterDefaultHandlers(EmbeddedTestServer* server);
49
50 // Returns a path that serves |original_path| with text that matches
51 // |text_to_replace| with the corresponding values, and then returns the
52 // resulting path in |replacement_path|.
53 void GetFilePathWithReplacements(const std::string& original_path,
54 const base::StringPairs& text_to_replace,
55 std::string* replacement_path);
56
57 } // namespace test_server
58 } // namespace net
59
60 #endif // NET_TEST_EMBEDDED_TEST_SERVER_REQUEST_HELPERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698