facebook / facebook/hhvm

Auto Content-Encoding: gzip and Transfer-Encoding: chunked only if necessary

Open
#4,886 1 comment 0 reactions 0 assignees View on GitHub
webserver
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

HHVM currently (Version 3.5.1) adds the following HTTP headers automatically:

```
Content-Encoding: gzip
Transfer-Encoding: chunked
```

But sometimes it's necessary / useful to decide in the acutual script if Content-Encoding/Transfer-Encoding is necessary or not and which values they should have.

It's also not possible to set the Content-Length header in a script because this gets overwritten by Transfer-Encoding: chunked.

Use-cases are:
- Webservices where you should be able to disable Content-Encoding because of compatibility reasons
- Dynamic downloads where you want to have a download progress in the client (Content-Length required, ...)

So there should be the possibility to disable this feature on the fly (in the script) or it needs to have a better auto detection.

Following the comparison of Zend and HHVM

Zend:

```
HTTP/1.1 200 OK
Date: Mon, 23 Feb 2015 11:03:35 GMT
Server: Apache/2.2.22 (Debian)
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: close
Content-Encoding: gzip
X-Powered-By: pimcore
Content-Length: 1503
Content-Type: application/json
```

HHVM

```
HTTP/1.1 200 OK
Date: Mon, 23 Feb 2015 11:03:09 GMT
Server: Apache/2.2.22 (Debian)
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Connection: close
Pragma: no-cache
Content-Encoding: gzip
Content-Encoding: gzip
X-Powered-By: pimcore
X-Powered-By: HHVM/3.5.1
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Transfer-Encoding: chunked
Content-Type: application/json
```

As you can see, ... HHVM adds another Content-Encoding header although there's already one set by the script and it removes the Content-Length header and adds Transfer-Encoding: chunked instead.

A workaround for now is to add the following configuration into the server.ini - but this disables this feature completely which isn't optimal in my opinion:

```
hhvm.server.gzip_compression_level = 0
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.