Repository navigation
Conversation
The WEBrick handlers copied only Content-Type from the response, so with content_encoding gzip /metrics sent a gzip body without the Content-Encoding header. Net::HTTP then did not decode the worker responses and /aggregated_metrics returned 500. Copy all the response headers in both handlers. Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
Watson1978
left a comment
There was a problem hiding this comment.
Thanks for the follow-up to #275.
I checked this on the PR head and on the merge result with the current master, which includes #275.
- With
<ssl>extra_confandcontent_encoding gzip, master serves/metricswithoutContent-Encodingand/aggregated_metricsreturns 500. With this PR both return 200 withContent-Encoding: gzip. This also holds withworkers 2, and the aggregated output has the metrics of both workers. - The new specs fail on master and pass on this branch.
One change is needed for the default content_encoding identity. See the inline comment.
I could not test the IPv6 bind path because IPv6 is disabled on my machine. It uses the same handlers as the extra_conf path, though.
| status, header, body = all_metrics | ||
| res.status = status | ||
| res['Content-Type'] = header['Content-Type'] | ||
| header.each { |name, value| res[name] = value } |
There was a problem hiding this comment.
MUST: This also copies Content-Encoding: identity when content_encoding is identity, which is the default. On master, the WEBrick path sends no Content-Encoding for these responses.
This changes a setup that works on master. nginx does not compress an upstream response that already has a Content-Encoding header. I put nginx with gzip on; gzip_proxied any; gzip_types *; in front of <ssl> extra_conf with the default settings. On master, nginx compressed /metrics and /aggregated_metrics from 3060 to 538 bytes. With this PR, both stay at 3060 bytes and carry Content-Encoding: identity.
The http_server helper path already sends identity, but changing that is out of scope here. Please keep these points in both WEBrick handlers (this line and line 206):
- With
identity, send noContent-Encodingheader, as on master. - With
gzip, sendContent-Encoding: gzip, as this PR does now. - On the 500 error response, send no
Content-Encodingheader, as on master.
Note that res['Content-Encoding'] = nil does not remove the header in WEBrick. It sends an empty Content-Encoding: header.
Please also add a spec for the identity case. It should check that res['content-encoding'] is nil on both /metrics and /aggregated_metrics.
On master the WEBrick handlers sent no Content-Encoding header. Keep that for the default content_encoding identity, so that a proxy in front can still compress the response, and send it only for gzip. Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
|
Thanks. Pushed 6ea07c4. Both WEBrick handlers now go through
The header is skipped, not set to nil, so WEBrick does not send an empty New spec |
Follow-up to #275, from the review there.
When the plugin serves with WEBrick (an IPv6
bind, or<ssl>withextra_conf), themount_prochandlers copied onlyContent-Typefrom the response tuple. Withcontent_encoding gzip:/metricssent a gzip body with noContent-Encodingheader./aggregated_metricsreturned 500, because in this modedo_requestis the plain Net::HTTP one, and Net::HTTP only decodes the worker body when the header is there. The aggregator got gzip bytes.Both handlers now copy every header from the tuple, so they match the
http_serverhelper path.Test
New specs under
when extra_conf is usedrequest/metricsand/aggregated_metricsover WEBrick withcontent_encoding gzip. They check for a 200, forContent-Encoding: gzip, and that the body gunzips to the metrics. On master they fail withcontent-encodingnil on/metricsand a 500 on/aggregated_metrics.End to end with
workers 2,bind ::1,content_encoding gzip: