limit size of X-Druid-Response-Context header to 7K#2336
limit size of X-Druid-Response-Context header to 7K#2336himanshug merged 1 commit intoapache:masterfrom
Conversation
There was a problem hiding this comment.
The limit is probably on the bytes rather than chars so I think it would be better to writeValueAsBytes
There was a problem hiding this comment.
header bytes are encoded using ASCII, so 1 char = 1 byte
in the builder.header(String key, Object value), eventually somewhere value.toString() is called and encoded using ASCII . I tried passing a byte[] to builder.header(..) and in response I got [B@468a1ce3.
I have updated the comment.
There was a problem hiding this comment.
StringUtils.toUtf8(responseCtxString).length might not equal responseCtxString.length()
There was a problem hiding this comment.
what happens in utf8 multi-byte characters in headers?
There was a problem hiding this comment.
@drcrallen jetty would do a buffer.put((byte)(0xff&c)); see https://github.com/eclipse/jetty.project/blob/master/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java#L963
There was a problem hiding this comment.
@drcrallen @himanshug the most correct way would be to enable the JsonGenerator .Feature.ESCAPE_NON_ASCII feature in jackson to ensure we correctly escape all non-ascii characters, otherwise the resulting context may not be valid JSON.
There was a problem hiding this comment.
@xvrl i guess if we are worried about invalid json in the header, then we should really move towards having a first class "metadata" attribute in the query response payload and put the information there. header is not probably the right place as you are going to remove some stuff to make it valid json anyway.
|
@himanshug added a few more comments that got buried in the rebase, in case you don't see them. |
|
👍 |
|
@himanshug we don't have to get held up by the non-ascii stuff, but I feel having a header that might either be incomplete or mangled will have to be addressed at some point. +1 once we file an issue about the non-ascii mangling in reponse context |
limit size of X-Druid-Response-Context header to 7K
fixes #2331