You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/08/02 21:07:25 UTC
[1/2] mesos git commit: Libprocess: Fixed decoder to support
incremental URL parsing.
Repository: mesos
Updated Branches:
refs/heads/1.0.x 2181d109a -> 547d42f73
Libprocess: Fixed decoder to support incremental URL parsing.
Review: https://reviews.apache.org/r/50634
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a3f466c6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a3f466c6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a3f466c6
Branch: refs/heads/1.0.x
Commit: a3f466c6c3871bc2d73676626df50b1ad4284a6b
Parents: 2181d10
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Sat Jul 30 12:58:28 2016 -0700
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Tue Aug 2 12:40:35 2016 -0700
----------------------------------------------------------------------
3rdparty/libprocess/src/decoder.hpp | 70 +++++++++++++++++++-------------
1 file changed, 41 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/a3f466c6/3rdparty/libprocess/src/decoder.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/decoder.hpp b/3rdparty/libprocess/src/decoder.hpp
index c0cefd4..47cfc0f 100644
--- a/3rdparty/libprocess/src/decoder.hpp
+++ b/3rdparty/libprocess/src/decoder.hpp
@@ -101,6 +101,7 @@ private:
decoder->field.clear();
decoder->value.clear();
decoder->query.clear();
+ decoder->url.clear();
CHECK(decoder->request == nullptr);
@@ -154,38 +155,17 @@ private:
{
DataDecoder* decoder = (DataDecoder*) p->data;
CHECK_NOTNULL(decoder->request);
- int result = 0;
#if (HTTP_PARSER_VERSION_MAJOR >= 2)
// Reworked parsing for version >= 2.0.
- http_parser_url url;
- result = http_parser_parse_url(data, length, 0, &url);
-
- if (result == 0) {
- if (url.field_set & (1 << UF_PATH)) {
- decoder->request->url.path.append(
- data + url.field_data[UF_PATH].off,
- url.field_data[UF_PATH].len);
- }
-
- if (url.field_set & (1 << UF_FRAGMENT)) {
- if (decoder->request->url.fragment.isNone()) {
- decoder->request->url.fragment = "";
- }
- decoder->request->url.fragment->append(
- data + url.field_data[UF_FRAGMENT].off,
- url.field_data[UF_FRAGMENT].len);
- }
-
- if (url.field_set & (1 << UF_QUERY)) {
- decoder->query.append(
- data + url.field_data[UF_QUERY].off,
- url.field_data[UF_QUERY].len);
- }
- }
+ // The current http_parser library (version 2.6.2 and below)
+ // does not support incremental parsing of URLs. To compensate
+ // we incrementally collect the data and parse it in
+ // `on_message_complete`.
+ decoder->url.append(data, length);
#endif
- return result;
+ return 0;
}
static int on_header_field(http_parser* p, const char* data, size_t length)
@@ -245,6 +225,39 @@ private:
{
DataDecoder* decoder = (DataDecoder*) p->data;
+ CHECK_NOTNULL(decoder->request);
+
+#if (HTTP_PARSER_VERSION_MAJOR >= 2)
+ // Parse the URL. This data was incrementally built up during calls
+ // to `on_url`.
+ http_parser_url url;
+ http_parser_url_init(&url);
+ int parse_url =
+ http_parser_parse_url(decoder->url.data(), decoder->url.size(), 0, &url);
+
+ if (parse_url != 0) {
+ return parse_url;
+ }
+
+ if (url.field_set & (1 << UF_PATH)) {
+ decoder->request->url.path = std::string(
+ decoder->url.data() + url.field_data[UF_PATH].off,
+ url.field_data[UF_PATH].len);
+ }
+
+ if (url.field_set & (1 << UF_FRAGMENT)) {
+ decoder->request->url.fragment = std::string(
+ decoder->url.data() + url.field_data[UF_FRAGMENT].off,
+ url.field_data[UF_FRAGMENT].len);
+ }
+
+ if (url.field_set & (1 << UF_QUERY)) {
+ decoder->query = std::string(
+ decoder->url.data() + url.field_data[UF_QUERY].off,
+ url.field_data[UF_QUERY].len);
+ }
+#endif
+
// Parse the query key/values.
Try<hashmap<std::string, std::string>> decoded =
http::query::decode(decoder->query);
@@ -253,8 +266,6 @@ private:
return 1;
}
- CHECK_NOTNULL(decoder->request);
-
decoder->request->url.query = decoded.get();
Option<std::string> encoding =
@@ -291,6 +302,7 @@ private:
std::string field;
std::string value;
std::string query;
+ std::string url;
http::Request* request;
[2/2] mesos git commit: Added MESOS-5943 to 1.0.1 CHANGELOG.
Posted by jo...@apache.org.
Added MESOS-5943 to 1.0.1 CHANGELOG.
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/547d42f7
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/547d42f7
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/547d42f7
Branch: refs/heads/1.0.x
Commit: 547d42f73752e4ef5402aa45c1cda9ac5c96acdd
Parents: a3f466c
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Tue Aug 2 13:56:53 2016 -0700
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Tue Aug 2 13:57:54 2016 -0700
----------------------------------------------------------------------
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/547d42f7/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index 47dd5db..33eaa51 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@ All Issues:
* [MESOS-5911] - webUI redirection to leader in browser does not work.
* [MESOS-5913] - Stale socket FD usage when using libevent + SSL.
* [MESOS-5923] - Ubuntu 14.04 LTS GPU Isolator "/run" directory is noexec.
+ * [MESOS-5943] - Incremental http parsing of URLs leads to decoder error.
* [MESOS-5945] - NvidiaVolume::create() should check for root before creating volume.
* [MESOS-5959] - All non-root tests fail on GPU machine.