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 2013/07/19 22:47:53 UTC

git commit: Fixed a bug in http::get when called with an empty query. Added the Host header to be HTTP 1.1 compliant.

Updated Branches:
  refs/heads/master ade2708f9 -> 84b2ce626


Fixed a bug in http::get when called with an empty query. Added the Host header to be HTTP 1.1 compliant.

Review: https://reviews.apache.org/r/12773


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/84b2ce62
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/84b2ce62
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/84b2ce62

Branch: refs/heads/master
Commit: 84b2ce62637eafbfc1f9383ae78a8b689bea5163
Parents: ade2708
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Fri Jul 19 12:00:46 2013 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Fri Jul 19 13:47:38 2013 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/process.cpp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/84b2ce62/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index a5e7031..443acfd 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -3615,8 +3615,17 @@ Future<Response> get(const UPID& upid, const string& path, const string& query)
 
   std::ostringstream out;
 
-  // TODO(bmahler): Add the Host header for HTTP 1.1.
-  out << "GET /" << upid.id << "/" << path << "?" << query << " HTTP/1.1\r\n"
+  if (query.empty()) {
+    out << "GET /" << upid.id << "/" << path << " HTTP/1.1\r\n";
+  } else {
+    out << "GET /" << upid.id << "/" << path << "?" << query << " HTTP/1.1\r\n";
+  }
+
+  // Call inet_ntop since inet_ntoa is not thread-safe!
+  char ip[INET_ADDRSTRLEN];
+  PCHECK(inet_ntop(AF_INET, (in_addr *) &upid.ip, ip, INET_ADDRSTRLEN) != NULL);
+
+  out << "Host: " << ip << ":" << upid.port << "\r\n"
       << "Connection: close\r\n"
       << "\r\n";