-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content-Length missing if Vary is present #1675
Comments
Mind providing us a test case? Are you using the HttpURLConnection API? |
FYI: This looks similar to a report against Android. I asked a similar question there. |
@nfuller That's my report, actually. @swankjesse Sure, apologies for being short on details. Unfortunately though, I was testing against internal URLs so it won't help to have those, but I can give you the exact responses and some other details. And this is using v2.3.0. First, this actually breaks in Glide as well if you wish to take a peek at how they're setting it up: https://github.com/bumptech/glide/blob/master/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpStreamFetcher.java As for my own testing, it's basically the following, using all defaults and the most basic setup possible: OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(mUrl)
.build();
Response response = client.newCall(request).execute();
Log.d("VaryTest", "Vary: " + response.header("Vary"));
Log.d("VaryTest", "Content-Length: " + response.header("Content-Length")); Without Vary, it looks like this: With Vary, it looks like this: The same two calls with cURL, all headers included (curl -i). With Vary: Doing a diff on the output of both cURL calls shows no difference, so I know the file is being served by Apache the exact same way in both cases, of course the only difference being that one has the Vary header. Is there anything else I can provide you with? |
I forgot to include it, but using response.body().contentLength() in the above example acts similarly. |
I realize I wasn't setting the Accept-Encoding header in the request in cURL, which does indeed make a difference in what was actually being served there (the server was using the old deflate module). Apologies. I guess this is one of those "d'oh" moments. Working as intended. |
Both
Response.header("Content-Length")
andResponse.body().contentLength()
are empty if the "Vary" header is set in the response. In my test case, the exact Vary header wasVary: Accept-Encoding,User-Agent
.Edit: The response was not compressed or changed in any way other than the Vary header being present.
The text was updated successfully, but these errors were encountered: