You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2014/11/21 02:41:21 UTC

mesos git commit: Made libprocess generate valid HTTP.

Repository: mesos
Updated Branches:
  refs/heads/master 0f1160b1b -> 993dc2dc5


Made libprocess generate valid HTTP.

While working on a pure Scala driver for Mesos, I discovered that
libprocess does not generate valid HTTP. It uses chunked encoding
combined with HTTP 1.0, which has only been added in HTTP
1.1. Additionally it stores the PID in the User-Agent field with an
incompatibe format ('@' and ':' are not allowed). This patch sets the
HTTP version to 1.1, adds an empty Host header (Host is mandatory in
1.1) and adds the Libprocess-From header. The User-Agent header is
left untouched for backwards compatibility reasons. Even strict HTTP
parser shouldn't error, but just ignore everything between the invalid
character and the CRLF.

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


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

Branch: refs/heads/master
Commit: 993dc2dc5389847a4da838a842bdbeff34031389
Parents: 0f1160b
Author: Dario Rexin <da...@mesosphere.io>
Authored: Thu Nov 20 17:41:08 2014 -0800
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Thu Nov 20 17:41:09 2014 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/src/encoder.hpp             | 7 +++++--
 3rdparty/libprocess/src/tests/process_tests.cpp | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/993dc2dc/3rdparty/libprocess/src/encoder.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/encoder.hpp b/3rdparty/libprocess/src/encoder.hpp
index 2b0d83f..7331e28 100644
--- a/3rdparty/libprocess/src/encoder.hpp
+++ b/3rdparty/libprocess/src/encoder.hpp
@@ -122,9 +122,12 @@ public:
       if (message->to.id != "") {
         out << "/" << message->to.id;
       }
-      out << "/" << message->name << " HTTP/1.0\r\n"
+
+      out << "/" << message->name << " HTTP/1.1\r\n"
           << "User-Agent: libprocess/" << message->from << "\r\n"
-          << "Connection: Keep-Alive\r\n";
+          << "Libprocess-From: " << message->from << "\r\n"
+          << "Connection: Keep-Alive\r\n"
+          << "Host: \r\n";
 
       if (message->body.size() > 0) {
         out << "Transfer-Encoding: chunked\r\n\r\n"

http://git-wip-us.apache.org/repos/asf/mesos/blob/993dc2dc/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 902d4d3..dec62e8 100644
--- a/3rdparty/libprocess/src/tests/process_tests.cpp
+++ b/3rdparty/libprocess/src/tests/process_tests.cpp
@@ -1541,7 +1541,7 @@ TEST(Process, http2)
   int c = ::accept(s, (sockaddr*) &addr, &addrlen);
   ASSERT_LT(0, c);
 
-  const string data = "POST /" + name + " HTTP/1.0";
+  const string data = "POST /" + name + " HTTP/1.1";
   EXPECT_SOME_EQ(data, os::read(c, data.size()));
 
   close(c);