Re-ordered and updated documentation for http::get/post/put. Review: https://reviews.apache.org/r/32348
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/103b6ea3 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/103b6ea3 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/103b6ea3 Branch: refs/heads/master Commit: 103b6ea318abe1b515ba1a48da589a93f2da5757 Parents: 50fd69a Author: Benjamin Mahler <[email protected]> Authored: Fri Mar 20 14:23:35 2015 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Tue Mar 24 16:48:22 2015 -0700 ---------------------------------------------------------------------- 3rdparty/libprocess/include/process/http.hpp | 46 ++++++++++--------- 3rdparty/libprocess/src/http.cpp | 56 +++++++++++------------ 2 files changed, 53 insertions(+), 49 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/103b6ea3/3rdparty/libprocess/include/process/http.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/include/process/http.hpp b/3rdparty/libprocess/include/process/http.hpp index 332f939..616f380 100644 --- a/3rdparty/libprocess/include/process/http.hpp +++ b/3rdparty/libprocess/include/process/http.hpp @@ -521,24 +521,27 @@ std::ostream& operator << ( const URL& url); -// Asynchronously sends an HTTP GET request to the specified URL and -// returns the HTTP response. +// Asynchronously sends an HTTP GET request to the specified URL +// and returns the HTTP response of type 'BODY' once the entire +// response is received. Future<Response> get( const URL& url, const Option<hashmap<std::string, std::string>>& headers = None()); -// Asynchronously sends an HTTP PUT request to the specified URL and -// returns the HTTP response. -Future<Response> put( - const URL& url, - const Option<hashmap<std::string, std::string>>& headers = None(), - const Option<std::string>& body = None(), - const Option<std::string>& contentType = None()); +// Asynchronously sends an HTTP GET request to the process with the +// given UPID and returns the HTTP response of type 'BODY' once the +// entire response is received. +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()); -// Asynchronously sends an HTTP POST request to the specified URL and -// returns the HTTP response. +// Asynchronously sends an HTTP POST request to the specified URL +// and returns the HTTP response of type 'BODY' once the entire +// response is received. Future<Response> post( const URL& url, const Option<hashmap<std::string, std::string>>& headers = None(), @@ -546,17 +549,9 @@ Future<Response> post( const Option<std::string>& contentType = None()); -// Asynchronously sends an HTTP GET request to the process with the -// given UPID and returns the HTTP response from the process. -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()); - - // Asynchronously sends an HTTP POST request to the process with the -// given UPID and returns the HTTP response from the process. +// given UPID and returns the HTTP response of type 'BODY' once the +// entire response is received. Future<Response> post( const UPID& upid, const Option<std::string>& path = None(), @@ -564,6 +559,15 @@ Future<Response> post( const Option<std::string>& body = None(), const Option<std::string>& contentType = None()); + +// Asynchronously sends an HTTP PUT request to the specified URL and +// returns the HTTP response. +Future<Response> put( + const URL& url, + const Option<hashmap<std::string, std::string>>& headers = None(), + const Option<std::string>& body = None(), + const Option<std::string>& contentType = None()); + } // namespace http { } // namespace process { http://git-wip-us.apache.org/repos/asf/mesos/blob/103b6ea3/3rdparty/libprocess/src/http.cpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp index a7eeee9..248db85 100644 --- a/3rdparty/libprocess/src/http.cpp +++ b/3rdparty/libprocess/src/http.cpp @@ -687,34 +687,6 @@ Future<Response> get( } -Future<Response> put( - const URL& url, - const Option<hashmap<string, string>>& headers, - const Option<string>& body, - const Option<string>& contentType) -{ - if (body.isNone() && contentType.isSome()) { - return Failure("Attempted to do a PUT with a Content-Type but no body"); - } - - return internal::request(url, "PUT", headers, body, contentType); -} - - -Future<Response> post( - const URL& url, - const Option<hashmap<string, string>>& headers, - const Option<string>& body, - const Option<string>& contentType) -{ - if (body.isNone() && contentType.isSome()) { - return Failure("Attempted to do a POST with a Content-Type but no body"); - } - - return internal::request(url, "POST", headers, body, contentType); -} - - Future<Response> get( const UPID& upid, const Option<string>& path, @@ -744,6 +716,20 @@ Future<Response> get( Future<Response> post( + const URL& url, + const Option<hashmap<string, string>>& headers, + const Option<string>& body, + const Option<string>& contentType) +{ + if (body.isNone() && contentType.isSome()) { + return Failure("Attempted to do a POST with a Content-Type but no body"); + } + + return internal::request(url, "POST", headers, body, contentType); +} + + +Future<Response> post( const UPID& upid, const Option<string>& path, const Option<hashmap<string, string>>& headers, @@ -760,5 +746,19 @@ Future<Response> post( return post(url, headers, body, contentType); } + +Future<Response> put( + const URL& url, + const Option<hashmap<string, string>>& headers, + const Option<string>& body, + const Option<string>& contentType) +{ + if (body.isNone() && contentType.isSome()) { + return Failure("Attempted to do a PUT with a Content-Type but no body"); + } + + return internal::request(url, "PUT", headers, body, contentType); +} + } // namespace http { } // namespace process {
