You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2015/09/28 20:27:19 UTC
[05/10] mesos git commit: Introduced a typedef to make consistent use
of case-insentitive http headers easier.
Introduced a typedef to make consistent use of case-insentitive http headers easier.
Review: https://reviews.apache.org/r/38600
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/bf207e36
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/bf207e36
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/bf207e36
Branch: refs/heads/master
Commit: bf207e368dcfbf33315dae094e9a91bcd51cc135
Parents: c9d2017
Author: Benjamin Mahler <be...@gmail.com>
Authored: Mon Sep 21 19:55:28 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Sep 28 10:50:51 2015 -0700
----------------------------------------------------------------------
3rdparty/libprocess/include/process/http.hpp | 36 ++++++++++----------
3rdparty/libprocess/src/http.cpp | 28 +++++++--------
3rdparty/libprocess/src/tests/http_tests.cpp | 4 +--
3rdparty/libprocess/src/tests/process_tests.cpp | 6 ++--
4 files changed, 37 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/bf207e36/3rdparty/libprocess/include/process/http.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/http.hpp b/3rdparty/libprocess/include/process/http.hpp
index 5932af4..e32607b 100644
--- a/3rdparty/libprocess/include/process/http.hpp
+++ b/3rdparty/libprocess/include/process/http.hpp
@@ -145,6 +145,12 @@ struct CaseInsensitiveEqual
};
+typedef hashmap<std::string,
+ std::string,
+ CaseInsensitiveHash,
+ CaseInsensitiveEqual> Headers;
+
+
struct Request
{
std::string method;
@@ -155,10 +161,7 @@ struct Request
// For server requests, the URL may be a URI or a relative reference.
URL url;
- hashmap<std::string,
- std::string,
- CaseInsensitiveHash,
- CaseInsensitiveEqual> headers;
+ Headers headers;
// TODO(bmahler): Add a 'query' field which contains both
// the URL query and the parsed form data from the body.
@@ -356,10 +359,7 @@ struct Response
// TODO(benh): Add major/minor version.
std::string status;
- hashmap<std::string,
- std::string,
- CaseInsensitiveHash,
- CaseInsensitiveEqual> headers;
+ Headers headers;
// Either provide a 'body', an absolute 'path' to a file, or a
// 'pipe' for streaming a response. Distinguish between the cases
@@ -723,7 +723,7 @@ std::string encode(const hashmap<std::string, std::string>& query);
// response is received.
Future<Response> get(
const URL& url,
- const Option<hashmap<std::string, std::string>>& headers = None());
+ const Option<Headers>& headers = None());
// Asynchronously sends an HTTP GET request to the process with the
@@ -733,7 +733,7 @@ Future<Response> get(
const UPID& upid,
const Option<std::string>& path = None(),
const Option<std::string>& query = None(),
- const Option<hashmap<std::string, std::string>>& headers = None());
+ const Option<Headers>& headers = None());
// Asynchronously sends an HTTP POST request to the specified URL
@@ -741,7 +741,7 @@ Future<Response> get(
// response is received.
Future<Response> post(
const URL& url,
- const Option<hashmap<std::string, std::string>>& headers = None(),
+ const Option<Headers>& headers = None(),
const Option<std::string>& body = None(),
const Option<std::string>& contentType = None());
@@ -752,7 +752,7 @@ Future<Response> post(
Future<Response> post(
const UPID& upid,
const Option<std::string>& path = None(),
- const Option<hashmap<std::string, std::string>>& headers = None(),
+ const Option<Headers>& headers = None(),
const Option<std::string>& body = None(),
const Option<std::string>& contentType = None());
@@ -767,7 +767,7 @@ Future<Response> post(
*/
Future<Response> requestDelete(
const URL& url,
- const Option<hashmap<std::string, std::string>>& headers = None());
+ const Option<Headers>& headers = None());
/**
@@ -783,7 +783,7 @@ Future<Response> requestDelete(
Future<Response> requestDelete(
const UPID& upid,
const Option<std::string>& path = None(),
- const Option<hashmap<std::string, std::string>>& headers = None());
+ const Option<Headers>& headers = None());
namespace streaming {
@@ -794,7 +794,7 @@ namespace streaming {
// from the Pipe::Reader.
Future<Response> get(
const URL& url,
- const Option<hashmap<std::string, std::string>>& headers = None());
+ const Option<Headers>& headers = None());
// Asynchronously sends an HTTP GET request to the process with the
// given UPID and returns the HTTP response of type 'PIPE' once the
@@ -804,7 +804,7 @@ Future<Response> get(
const UPID& upid,
const Option<std::string>& path = None(),
const Option<std::string>& query = None(),
- const Option<hashmap<std::string, std::string>>& headers = None());
+ const Option<Headers>& headers = None());
// Asynchronously sends an HTTP POST request to the specified URL
// and returns the HTTP response of type 'PIPE' once the response
@@ -812,7 +812,7 @@ Future<Response> get(
// from the Pipe::Reader.
Future<Response> post(
const URL& url,
- const Option<hashmap<std::string, std::string>>& headers = None(),
+ const Option<Headers>& headers = None(),
const Option<std::string>& body = None(),
const Option<std::string>& contentType = None());
@@ -823,7 +823,7 @@ Future<Response> post(
Future<Response> post(
const UPID& upid,
const Option<std::string>& path = None(),
- const Option<hashmap<std::string, std::string>>& headers = None(),
+ const Option<Headers>& headers = None(),
const Option<std::string>& body = None(),
const Option<std::string>& contentType = None());
http://git-wip-us.apache.org/repos/asf/mesos/blob/bf207e36/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index b4ab772..c93e7e0 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -762,7 +762,7 @@ Future<Response> _request(
const URL& url,
const string& method,
bool streamingResponse,
- const Option<hashmap<string, string>>& _headers,
+ const Option<Headers>& _headers,
const Option<string>& body,
const Option<string>& contentType);
@@ -771,7 +771,7 @@ Future<Response> request(
const URL& url,
const string& method,
bool streamedResponse,
- const Option<hashmap<string, string>>& headers,
+ const Option<Headers>& headers,
const Option<string>& body,
const Option<string>& contentType)
{
@@ -838,7 +838,7 @@ Future<Response> _request(
const URL& url,
const string& method,
bool streamedResponse,
- const Option<hashmap<string, string>>& _headers,
+ const Option<Headers>& _headers,
const Option<string>& body,
const Option<string>& contentType)
{
@@ -864,7 +864,7 @@ Future<Response> _request(
out << " HTTP/1.1\r\n";
// Set up the headers as necessary.
- hashmap<string, string> headers;
+ Headers headers;
if (_headers.isSome()) {
headers = _headers.get();
@@ -937,7 +937,7 @@ Future<Response> _request(
Future<Response> get(
const URL& url,
- const Option<hashmap<string, string>>& headers)
+ const Option<Headers>& headers)
{
return internal::request(url, "GET", false, headers, None(), None());
}
@@ -947,7 +947,7 @@ Future<Response> get(
const UPID& upid,
const Option<string>& path,
const Option<string>& query,
- const Option<hashmap<string, string>>& headers)
+ const Option<Headers>& headers)
{
URL url("http", net::IP(upid.address.ip), upid.address.port, upid.id);
@@ -973,7 +973,7 @@ Future<Response> get(
Future<Response> post(
const URL& url,
- const Option<hashmap<string, string>>& headers,
+ const Option<Headers>& headers,
const Option<string>& body,
const Option<string>& contentType)
{
@@ -988,7 +988,7 @@ Future<Response> post(
Future<Response> post(
const UPID& upid,
const Option<string>& path,
- const Option<hashmap<string, string>>& headers,
+ const Option<Headers>& headers,
const Option<string>& body,
const Option<string>& contentType)
{
@@ -1005,7 +1005,7 @@ Future<Response> post(
Future<Response> requestDelete(
const URL& url,
- const Option<hashmap<string, string>>& headers)
+ const Option<Headers>& headers)
{
return internal::request(url, "DELETE", false, headers, None(), None());
}
@@ -1014,7 +1014,7 @@ Future<Response> requestDelete(
Future<Response> requestDelete(
const UPID& upid,
const Option<string>& path,
- const Option<hashmap<string, string>>& headers)
+ const Option<Headers>& headers)
{
URL url("http", net::IP(upid.address.ip), upid.address.port, upid.id);
@@ -1033,7 +1033,7 @@ namespace streaming {
Future<Response> get(
const URL& url,
- const Option<hashmap<string, string>>& headers)
+ const Option<Headers>& headers)
{
return internal::request(url, "GET", true, headers, None(), None());
}
@@ -1043,7 +1043,7 @@ Future<Response> get(
const UPID& upid,
const Option<string>& path,
const Option<string>& query,
- const Option<hashmap<string, string>>& headers)
+ const Option<Headers>& headers)
{
URL url("http", net::IP(upid.address.ip), upid.address.port, upid.id);
@@ -1069,7 +1069,7 @@ Future<Response> get(
Future<Response> post(
const URL& url,
- const Option<hashmap<string, string>>& headers,
+ const Option<Headers>& headers,
const Option<string>& body,
const Option<string>& contentType)
{
@@ -1084,7 +1084,7 @@ Future<Response> post(
Future<Response> post(
const UPID& upid,
const Option<string>& path,
- const Option<hashmap<string, string>>& headers,
+ const Option<Headers>& headers,
const Option<string>& body,
const Option<string>& contentType)
{
http://git-wip-us.apache.org/repos/asf/mesos/blob/bf207e36/3rdparty/libprocess/src/tests/http_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/http_tests.cpp b/3rdparty/libprocess/src/tests/http_tests.cpp
index a52561e..c380f35 100644
--- a/3rdparty/libprocess/src/tests/http_tests.cpp
+++ b/3rdparty/libprocess/src/tests/http_tests.cpp
@@ -127,7 +127,7 @@ TEST(HTTPTest, Auth)
noAuthFuture.get().headers.get("WWW-authenticate"));
// Now test passing wrong auth header.
- hashmap<string, string> headers;
+ http::Headers headers;
headers["Authorization"] = "Basic " + base64::encode("testuser:wrongpass");
Future<http::Response> wrongAuthFuture =
@@ -606,7 +606,7 @@ TEST(HTTPTest, Post)
ASSERT_EQ(http::statuses[200], future.get().status);
// Now test passing headers instead.
- hashmap<string, string> headers;
+ http::Headers headers;
headers["Content-Type"] = "text/plain";
EXPECT_CALL(*http.process, post(_))
http://git-wip-us.apache.org/repos/asf/mesos/blob/bf207e36/3rdparty/libprocess/src/tests/process_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/process_tests.cpp b/3rdparty/libprocess/src/tests/process_tests.cpp
index 1023500..ffd260a 100644
--- a/3rdparty/libprocess/src/tests/process_tests.cpp
+++ b/3rdparty/libprocess/src/tests/process_tests.cpp
@@ -1371,7 +1371,7 @@ TEST(ProcessTest, Http1)
.WillOnce(DoAll(FutureArg<0>(&pid),
FutureArg<1>(&body)));
- hashmap<string, string> headers;
+ http::Headers headers;
headers["User-Agent"] = "libprocess/";
Future<http::Response> response =
@@ -1419,7 +1419,7 @@ TEST(ProcessTest, Http2)
.WillOnce(DoAll(FutureArg<0>(&pid),
FutureArg<1>(&body)));
- hashmap<string, string> headers;
+ http::Headers headers;
headers["Libprocess-From"] = stringify(from);
Future<http::Response> response =
@@ -1745,7 +1745,7 @@ TEST(ProcessTest, PercentEncodedURLs)
EXPECT_CALL(process, handler1(_, _))
.WillOnce(FutureSatisfy(&handler1));
- hashmap<string, string> headers;
+ http::Headers headers;
headers["User-Agent"] = "libprocess/";
Future<http::Response> response = http::post(pid, "handler1", headers);