Accept-Encoding in volley not responding with Content-Encoding

I am developing Restful Api. I am using laravel as backend (with apache) and for client I am using Android (with volleyball library for network communications).

In one of my calls, I have the following:

JsonArrayRequest jsonObjReq = new JsonArrayRequest(url,
new Response.Listener<JSONArray>() {

public void onResponse(JSONArray response) {
    Log.d("Response", response.toString());
}, new Response.ErrorListener() {

    public void onErrorResponse(VolleyError error) {

    protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
        for (Map.Entry<String, String> e: response.headers.entrySet()){
            Log.d(e.getKey(), e.getValue());
        return super.parseNetworkResponse(response);

    public Map<String, String> getHeaders() throws AuthFailureError {
        Map<String, String> map = new HashMap<String, String>();
        return map;


As you can see, I have installed Accept-Encoding :gzip,deflate


When laravel receives a request, the headers exist:

array (
  'accept-encoding' => 
  array (
    0 => 'gzip,deflate',
  'host' => 
  array (
    0 => '',
  'connection' => 
  array (
    0 => 'Keep-Alive',
  'user-agent' => 
  array (
    0 => 'Apache-HttpClient/UNAVAILABLE (java 1.5)',
  'cookie' => 
  array (
    0 => 'laravel_session=,
  'cookie2' => 
  array (
    0 => '$Version=1',


But when android receives a response, it does not contain the header Content-Encoding : gzip

, the headers it contains:

Transfer-Encoding﹕ chunked
Date﹕ Sun, 21 Sep 2014 15:15:37 GMT
Keep-Alive﹕ timeout=5, max=99
Set-Cookie﹕ laravel_session=
Content-Type﹕ application/json
X-Powered-By﹕ PHP/5.4.9-4ubuntu2.4
Server﹕ Apache/2.2.22 (Ubuntu)
Cache-Control﹕ no-cache


When I make the same request via curl:

curl -I -H 'Accept-Encoding: gzip' url


it returns:

HTTP/1.1 200 OK
Date: Sun, 21 Sep 2014 14:46:12 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.4.9-4ubuntu2.4
Cache-Control: no-cache
Set-Cookie: laravel_session=
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Type: text/html; charset=UTF-8


So, to summarize, I am setting Accept-Encoding:gzip,deflate

, the request is received by the bb server with these headers, but when the response is received by android Content-Encoding

does not exist. This is not my server problem, because curl works well.

Any suggestion? thank


I am looking at data sent and received using Wireshark between Android and my server. I am looking at another request from this. This other request is done with JsonObjectRequest

instead JsonArrayRequest

, and with wireshark I can watch the following headers.

Android -> Server

Content-Type: application/json\r\n
Connection: Keep-Alive\r\n
User-Agent: Apache-HttpClient/UNAVAILABLE (java 1.5)\r\n
[truncated] Cookie: laravel_session=
Cookie2: $Version=1\r\n
Accept-Encoding: gzip,deflate\r\n


Server -> android

Date: Sun, 21 Sep 2014 18:59:15 GMT\r\n
Server: Apache/2.2.22 (Ubuntu)\r\n
X-Powered-By: PHP/5.4.9-4ubuntu2.4\r\n
Cache-Control: no-cache\r\n
[truncated] Set-Cookie: laravel_session=
Vary: Accept-Encoding\r\n
Content-Encoding: gzip\r\n
Connection: Keep-Alive\r\n
Transfer-Encoding: chunked\r\n
Content-Type: text/html; charset=UTF-8\r\n


In this request, the response contains Content-Encoding: gzip

. The only difference between this request and the other is that this request uses JsonObjectRequest

instead JsonArrayRequest

, so cant'JsonArrayRequest uses Gzip encode?


source to share

All Articles