Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

Lost content-length header fix #86

Merged
merged 1 commit into from
Aug 21, 2016

Conversation

francisco-sanchez-molina
Copy link
Contributor

No description provided.

@wkh237
Copy link
Owner

wkh237 commented Aug 14, 2016

@francisco-sanchez-molina , thanks for the PR.

I've noticed that request on Android does not contains Content-Length field but IOS does, after some simple tests.

However, when I try to add these lines to Android, it throws an error. After some investigation, the Content-Type field is created by OkHttp conditionally per this.

Therefore, I'm not sure if this change is necessary 😧

@francisco-sanchez-molina
Copy link
Contributor Author

francisco-sanchez-molina commented Aug 15, 2016

Hi @wkh237 !

I sent a photo of camera-roll and everything was fine, including content-length header.

In Request-body api ( https://square.github.io/okhttp/3.x/okhttp/okhttp3/RequestBody.html ) I found:
long contentLength() Returns the number of bytes that will be written to out in a call to writeTo(okio.BufferedSink), or -1 if that count is unknown.

So I think it is necessary.

If it throws an exception, it may be because the variable contentLength has an incorrect value in some cases

thanks you so much!

@MQZhangThu
Copy link

MQZhangThu commented Aug 17, 2016

hi, @francisco-sanchez-molina

I have the same problem and I am wondering how did you calculate the content-length value? thx.

@wkh237 wkh237 merged commit 9f9f65b into wkh237:master Aug 21, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants