[
https://issues.apache.org/jira/browse/TS-4018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15044166#comment-15044166
]
ASF GitHub Bot commented on TS-4018:
------------------------------------
Github user bryancall commented on a diff in the pull request:
https://github.com/apache/trafficserver/pull/362#discussion_r46776556
--- Diff: proxy/http2/HPACK.cc ---
@@ -332,18 +332,41 @@ int64_t
encode_string(uint8_t *buf_start, const uint8_t *buf_end, const char
*value, size_t value_len)
{
uint8_t *p = buf_start;
+ bool use_huffman = true;
+ char *data = NULL;
+ int64_t data_len = 0;
+
+ // TODO Choose whether to use Huffman encoding wisely
+
+ if (use_huffman) {
+ data = static_cast<char *>(ats_malloc(value_len * 4));
+ if (data == NULL)
+ return -1;
+ data_len = huffman_encode(reinterpret_cast<uint8_t *>(data),
reinterpret_cast<const uint8_t *>(value), value_len);
+ } else {
+ data = const_cast<char *>(value);
+ data_len = value_len;
+ }
// Length
- const int64_t len = encode_integer(p, buf_end, value_len, 7);
+ const int64_t len = encode_integer(p, buf_end, data_len, 7);
if (len == -1)
return -1;
+ if (use_huffman) {
+ *p |= 0x80;
+ }
p += len;
- if (buf_end < p || static_cast<size_t>(buf_end - p) < value_len)
+ if (buf_end < p || static_cast<size_t>(buf_end - p) < data_len)
--- End diff --
I get this error when compiling:
HPACK.cc:359:55: error: comparison between signed and unsigned integer
expressions [-Werror=sign-compare]
if (buf_end < p || static_cast<size_t>(buf_end - p) < data_len)
> Use the huffman encode in HPACK
> -------------------------------
>
> Key: TS-4018
> URL: https://issues.apache.org/jira/browse/TS-4018
> Project: Traffic Server
> Issue Type: Improvement
> Components: HTTP/2
> Reporter: Masakazu Kitajo
> Fix For: 6.1.0
>
>
> A huffman encoder is exist in the HPACK implementation (TS-3852) but it
> doesn't seem to be used. It isn't included in TS-3478 also.
> We could use the huffman encoder.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)