# Range request with Accept-Encoding:“gzip,deflate" for \*.pdf.\* file-name pattern returns 416

**URL:** <https://www.ruby-forum.com/t/range-request-with-accept-encoding-gzip-deflate-for-pdf-file-name-pattern-returns-416/244589>\
**Category:** NGINX\
**Created:** [May 9, 2016, 2:39pm UTC](https://www.ruby-forum.com/t/range-request-with-accept-encoding-gzip-deflate-for-pdf-file-name-pattern-returns-416/244589 "2016-05-09T14:39:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [May 9, 2016, 2:39pm UTC](https://www.ruby-forum.com/t/range-request-with-accept-encoding-gzip-deflate-for-pdf-file-name-pattern-returns-416/244589/1 "2016-05-09T14:39:59Z")

</div>

We are facing this weird behavior wherein if a range request with  
Accept-Encoding:“gzip,deflate" is called for a url having .pdf as part  
of  
path, nginx would throw 416 even if the range is well within overall  
size of  
source file

Also this happens for Range request “Range: bytes=20-” and above while  
same  
would work if its less that 20 bytes as start of range eg “Range:  
bytes=19-”

Nginx Version : 1.8.0

Sample curl

curl -v --user “xxx” -H “Host:yyy.com” --compressed -H “Range:  
bytes=20-”  
[https://yyy.com/api/v1/fs-content/Shared/0test/latest.pdf.test.txt](https://yyy.com/api/v1/fs-content/Shared/0test/latest.pdf.test.txt)

Response :

> GET /api/v1/fs-content/Shared/0test/latest.pdf.test.txt HTTP/1.1  
> User-Agent: curl/7.35.0  
> Accept: _/_  
> Accept-Encoding: deflate, gzip  
> Range: bytes=20-

\< HTTP/1.1 416 Requested Range Not Satisfiable  
\< Date: Mon, 09 May 2016 12:34:03 GMT  
\< Content-Type: text/html; charset=iso-8859-1  
\< Transfer-Encoding: chunked  
\< X-Content-Type-Options: nosniff  
\< X-XSS-Protection: 1; mode=block  
\< Strict-Transport-Security: max-age=31536000  
\<

200 OK
# OK

None of the range-specifier values in the Range request-header field overlap the current extent of the selected resource.

Sample access log

172.26.7.15 - [08/May/2016:23:03:20 -0700] “GET  
/public-api/v1/fs-content-download/Shared/0test/latest.pdf.test.txt  
HTTP/1.1” 416 466 “[qaaa.egnyte.com](http://qaaa.egnyte.com)” “-” “curl/7.19.7  
(x86\_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3  
libidn/1.18  
libssh2/1.4.2” “deflate, gzip” “D0536872:4496\_0A19800C:01BB\_–\_3B70C9”  
“-:bytes=20-” “” “-” “text/html; charset=iso-8859-1” “” “” “” “” “” “”  
“0.023” “0.023” “BYPASS”

Note :  
Earlier we had an issue with If-Range header value format to match with  
Etag  
value and had to add a patch mentioned here  
[http://permalink.gmane.org/gmane.comp.web.nginx.devel/2579](http://permalink.gmane.org/gmane.comp.web.nginx.devel/2579)

Kindly suggest.

Posted at Nginx Forum:

> **[Range request with Accept-Encoding:“gzip,deflate" for \*.pdf.\* file-name...](https://forum.nginx.org/read.php?2,266713,266713#msg-266713)**
>
> We are facing this weird behavior wherein if a range request with Accept-Encoding:“gzip,deflate" is called for a url having .pdf as part of path, nginx would throw 416 even if the range is well within overall size of source file Also this...

---

<div class="post-metadata">

**Author:** ![yogeshorai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/bcef8e/32.png) [@yogeshorai](https://www.ruby-forum.com/u/yogeshorai)\
**Post date:** [May 10, 2016, 4:41pm UTC](https://www.ruby-forum.com/t/range-request-with-accept-encoding-gzip-deflate-for-pdf-file-name-pattern-returns-416/244589/2 "2016-05-10T16:41:39Z")

</div>

Hello!

On Mon, May 09, 2016 at 08:39:31AM -0400, yogeshorai wrote:

> > Range: bytes=20-
> 
> 172.26.7.15 - [08/May/2016:23:03:20 -0700] “GET  
> /public-api/v1/fs-content-download/Shared/0test/latest.pdf.test.txt  
> HTTP/1.1” 416 466 “[qaaa.egnyte.com](http://qaaa.egnyte.com)” “-” “curl/7.19.7  
> (x86\_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18  
> libssh2/1.4.2” “deflate, gzip” “D0536872:4496\_0A19800C:01BB\_–\_3B70C9”  
> “-:bytes=20-” “” “-” “text/html; charset=iso-8859-1” “” “” “” “” “” “”  
> “0.023” “0.023” “BYPASS”

The response is returned by your backend, not by nginx. Try  
looking at your backend instead.

> Note :  
> Earlier we had an issue with If-Range header value format to match with Etag  
> value and had to add a patch mentioned here  
> [http://permalink.gmane.org/gmane.comp.web.nginx.devel/2579](http://permalink.gmane.org/gmane.comp.web.nginx.devel/2579)

The patch in question is only needed if your backend is broken and  
doesn’t follow HTTP standard. You may consider fixing your  
backend instead.

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![yogeshorai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/bcef8e/32.png) [@yogeshorai](https://www.ruby-forum.com/u/yogeshorai)\
**Post date:** [May 19, 2016, 1:44pm UTC](https://www.ruby-forum.com/t/range-request-with-accept-encoding-gzip-deflate-for-pdf-file-name-pattern-returns-416/244589/3 "2016-05-19T13:44:21Z")

</div>

Thnx maxim for pointing it out.  
We investigated further and issue seems to be at our back-end server.

Thanks a lot for your help

Posted at Nginx Forum:

> **[Re: Range request with Accept-Encoding:“gzip,deflate" for \*.pdf.\* file-name...](https://forum.nginx.org/read.php?2,266713,266998#msg-266998)**
>
> We are facing this weird behavior wherein if a range request with Accept-Encoding:“gzip,deflate" is called for a url having .pdf as part of path, nginx would throw 416 even if the range is well within overall size of source file Also this...
