You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2016/01/14 21:45:59 UTC

[1/2] trafficserver git commit: TS-4097: Encode empty string properly with HPACK

Repository: trafficserver
Updated Branches:
  refs/heads/6.1.x 74f92f4df -> a729933f6


TS-4097: Encode empty string properly with HPACK

This closes #395.

(cherry picked from commit 413dd51d5dc17bf388805071efdb8f882014b847)


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

Branch: refs/heads/6.1.x
Commit: be9d3ffd33c8b6d34f906dd362eeb1d68b31af7e
Parents: 74f92f4
Author: Masakazu Kitajo <ma...@apache.org>
Authored: Tue Dec 22 11:01:33 2015 +0900
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Jan 14 13:31:13 2016 -0700

----------------------------------------------------------------------
 proxy/http2/HPACK.cc           |  8 +++++---
 proxy/http2/RegressionHPACK.cc | 12 +++++++++---
 2 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/be9d3ffd/proxy/http2/HPACK.cc
----------------------------------------------------------------------
diff --git a/proxy/http2/HPACK.cc b/proxy/http2/HPACK.cc
index 51b9a2f..b54d923 100644
--- a/proxy/http2/HPACK.cc
+++ b/proxy/http2/HPACK.cc
@@ -338,7 +338,7 @@ encode_string(uint8_t *buf_start, const uint8_t *buf_end, const char *value, siz
 
   // TODO Choose whether to use Huffman encoding wisely
 
-  if (use_huffman) {
+  if (use_huffman && value_len) {
     data = static_cast<char *>(ats_malloc(value_len * 4));
     if (data == NULL)
       return -1;
@@ -369,8 +369,10 @@ encode_string(uint8_t *buf_start, const uint8_t *buf_end, const char *value, siz
   }
 
   // Value
-  memcpy(p, data, data_len);
-  p += data_len;
+  if (data_len) {
+    memcpy(p, data, data_len);
+    p += data_len;
+  }
 
   if (use_huffman) {
     ats_free(data);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/be9d3ffd/proxy/http2/RegressionHPACK.cc
----------------------------------------------------------------------
diff --git a/proxy/http2/RegressionHPACK.cc b/proxy/http2/RegressionHPACK.cc
index 5ceebc8..fe5ee71 100644
--- a/proxy/http2/RegressionHPACK.cc
+++ b/proxy/http2/RegressionHPACK.cc
@@ -53,9 +53,15 @@ const static struct {
   uint32_t raw_string_len;
   uint8_t *encoded_field;
   int encoded_field_len;
-} string_test_case[] = {{(char *)"custom-key", 10, (uint8_t *) "\xA"
+} string_test_case[] = {{(char *)"", 0,            (uint8_t *) "\x0"
+                                                               "",
+                         1},
+                        {(char *)"custom-key", 10, (uint8_t *) "\xA"
                                                                "custom-key",
                          11},
+                        {(char *)"", 0,            (uint8_t *) "\x80"
+                                                               "",
+                         1},
                         {(char *)"custom-key", 10, (uint8_t *) "\x88"
                                                                "\x25\xa8\x49\xe9\x5b\xa9\x7d\x7f",
                          9}};
@@ -232,13 +238,13 @@ REGRESSION_TEST(HPACK_EncodeString)(RegressionTest *t, int, int *pstatus)
   int len;
 
   // FIXME Current encoder support only huffman conding.
-  for (unsigned int i = 1; i < 2; i++) {
+  for (unsigned int i = 2; i < sizeof(string_test_case) / sizeof(string_test_case[0]); i++) {
     memset(buf, 0, BUFSIZE_FOR_REGRESSION_TEST);
 
     len = encode_string(buf, buf + BUFSIZE_FOR_REGRESSION_TEST, string_test_case[i].raw_string, string_test_case[i].raw_string_len);
 
     box.check(len == string_test_case[i].encoded_field_len, "encoded length was %d, expecting %d", len,
-              integer_test_case[i].encoded_field_len);
+              string_test_case[i].encoded_field_len);
     box.check(len > 0 && memcmp(buf, string_test_case[i].encoded_field, len) == 0, "encoded string was invalid");
   }
 }


[2/2] trafficserver git commit: TS-4097: clang-format

Posted by zw...@apache.org.
TS-4097: clang-format

(cherry picked from commit 419494bb4e0e34f99fa0ccdc6a8b66ec4e231924)


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

Branch: refs/heads/6.1.x
Commit: a729933f67ba93a353ac4b1afe7567b0a2dc9216
Parents: be9d3ff
Author: Bryan Call <bc...@apache.org>
Authored: Tue Jan 5 10:35:10 2016 -0800
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Jan 14 13:31:25 2016 -0700

----------------------------------------------------------------------
 proxy/http2/RegressionHPACK.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a729933f/proxy/http2/RegressionHPACK.cc
----------------------------------------------------------------------
diff --git a/proxy/http2/RegressionHPACK.cc b/proxy/http2/RegressionHPACK.cc
index fe5ee71..4756aea 100644
--- a/proxy/http2/RegressionHPACK.cc
+++ b/proxy/http2/RegressionHPACK.cc
@@ -53,14 +53,14 @@ const static struct {
   uint32_t raw_string_len;
   uint8_t *encoded_field;
   int encoded_field_len;
-} string_test_case[] = {{(char *)"", 0,            (uint8_t *) "\x0"
-                                                               "",
+} string_test_case[] = {{(char *)"", 0, (uint8_t *) "\x0"
+                                                    "",
                          1},
                         {(char *)"custom-key", 10, (uint8_t *) "\xA"
                                                                "custom-key",
                          11},
-                        {(char *)"", 0,            (uint8_t *) "\x80"
-                                                               "",
+                        {(char *)"", 0, (uint8_t *) "\x80"
+                                                    "",
                          1},
                         {(char *)"custom-key", 10, (uint8_t *) "\x88"
                                                                "\x25\xa8\x49\xe9\x5b\xa9\x7d\x7f",