<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p><span id="ms-rterangepaste-start"></span></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
Hello!<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
<o:p> </o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
A couple of years ago, I’ve reported the following bug:<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
<a href="http://mailman.nginx.org/pipermail/nginx-devel/2013-October/004442.html" style="color: rgb(17, 85, 204);" title="http://mailman.nginx.org/pipermail/nginx-devel/2013-October/004442.html
Ctrl+Click or tap to follow the link" id="LPlnk724654">http://mailman.nginx.org/pipermail/nginx-devel/2013-October/004442.html</a><o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
<o:p> </o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
Responses with empty bodies with the header “Content-Encoding: gzip” used to cause requests to hang.<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
There has been a fix, but now it seems that the requests simply fails.<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
<o:p> </o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
Reviewing the code, it appears that the following happens:<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
- An empty last buffer arrives into the gunzip module’s body filter.<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
- The gunzip module’s ngx_http_gunzip_filter_add_data() calculates and input buffer size (it is 0), and it is later in fed to zlib’s inflate(), along with the paramter Z_FINISH<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
- inflate() is later called, and returned Z_BUF_ERROR. This causes error handling to shut down the request and the connection. The client gets an empty response.<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
<o:p> </o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
I’m not sure what a proper fix would be, but I can suggest the following:<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
1. In ngx_http_gunzip_header_filter() check the content length, and don’t create a gunzip ctx if it is 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
2. In ngx_http_gunzip_body_filter(), check if gunzip has started (“!ctx->started”). If it hasn’t and the input buffer is the last one, simply jump to the next filter. This handles the case that the response with is chunked encoding.<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
<o:p> </o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
Would be great to hear the development team’s opinion.<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
<o:p> </o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
Best regards,<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
Aviram<o:p></o:p></p>
<p class="MsoNormal" style="margin-right: 0px; margin-left: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; direction: ltr;">
<o:p> </o:p></p>
<span id="ms-rterangepaste-end"></span><br>
<p></p>
</div>
</body>
</html>