 Chromium Code Reviews
 Chromium Code Reviews Issue 1376593007:
  SSL in EmbeddedTestServer  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1376593007:
  SSL in EmbeddedTestServer  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: net/test/embedded_test_server/request_helpers.h | 
| diff --git a/net/test/embedded_test_server/request_helpers.h b/net/test/embedded_test_server/request_helpers.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..e36be4f482eb1866a58acddc5b355ec96e4eb670 | 
| --- /dev/null | 
| +++ b/net/test/embedded_test_server/request_helpers.h | 
| @@ -0,0 +1,66 @@ | 
| +// Copyright 2015 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. | 
| + | 
| +#ifndef NET_TEST_EMBEDDED_TEST_SERVER_REQUEST_HELPERS_H_ | 
| +#define NET_TEST_EMBEDDED_TEST_SERVER_REQUEST_HELPERS_H_ | 
| + | 
| +#include <utility> | 
| + | 
| +#include "base/files/file_path.h" | 
| +#include "base/strings/string_split.h" | 
| +#include "net/test/embedded_test_server/embedded_test_server.h" | 
| +#include "net/test/embedded_test_server/http_request.h" | 
| +#include "net/test/embedded_test_server/http_response.h" | 
| +#include "url/gurl.h" | 
| + | 
| +namespace net { | 
| +namespace test_server { | 
| + | 
| +// This file is only meant for compatibility with testserver.py. No | 
| +// additional handlers should be added here that don't affect multiple | 
| +// distinct tests. | 
| + | 
| +using RequestQuery = std::map<std::string, std::vector<std::string>>; | 
| + | 
| +class CustomHttpResponse : public HttpResponse { | 
| + public: | 
| + CustomHttpResponse(const std::string& headers, const std::string& contents) | 
| + : 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.
 | 
| + | 
| + void SendResponse(SendBytesCallback send, SendCompleteCallback done) override; | 
| + | 
| + private: | 
| + std::string headers_; | 
| + std::string contents_; | 
| 
mmenke
2015/10/19 18:07:41
Make these const?
 
svaldez
2015/10/19 21:56:15
Done.
 | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(CustomHttpResponse); | 
| +}; | 
| + | 
| +// Return whether |request| starts with a URL path of |url|. | 
| +bool ShouldHandle(const HttpRequest& request, std::string prefix_path); | 
| + | 
| +// Calls |handler| if the |request| URL starts with |prefix|. | 
| +scoped_ptr<HttpResponse> HandlePrefixedRequest( | 
| + std::string prefix, | 
| 
mmenke
2015/10/19 18:07:41
const std::string&
 
svaldez
2015/10/19 21:56:15
Done.
 | 
| + EmbeddedTestServer::HandleRequestCallback handler, | 
| 
mmenke
2015/10/19 18:07:41
const EmbeddedTestServer::HandleRequestCallback&
 
svaldez
2015/10/19 21:56:15
Done.
 | 
| + const HttpRequest& request); | 
| + | 
| +// 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.
 | 
| +RequestQuery ParseQuery(const GURL& url); | 
| + | 
| +// Returns a path that serves |original_path| with text that matches | 
| +// |text_to_replace| with the corresponding values, and then returns the | 
| +// resulting path in |replacement_path|. | 
| +void GetFilePathWithReplacements(const std::string& original_path, | 
| + const base::StringPairs& text_to_replace, | 
| + 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
 | 
| + | 
| +// Handles |request| by serving a file from under |server_root|. | 
| +scoped_ptr<HttpResponse> HandleFileRequest(const base::FilePath& server_root, | 
| + const HttpRequest& request); | 
| + | 
| +} // namespace test_server | 
| +} // namespace net | 
| + | 
| +#endif // NET_TEST_EMBEDDED_TEST_SERVER_REQUEST_HELPERS_H_ |