Multipart - how to disable Content-Length for a part?
See original GitHub issueQuestion:
How to disable Content-Length
header for a part? I need to do this because an API that I’m using does not allow it (and I can’t do anything about it).
I’m sure that the problem is that header, because I’ve tried to upload a file manually using HttpURLConnection
and it works great without Content-Length
, and it fails immediately when I add it.
I’ve tried to add interceptor to the request (both addInterceptor
and addNetworkInterceptor
) in order to remove unwanted header. But it is not here (I can see only Content-Disposition
). Is there another way to disable it?
Mentioning https://github.com/square/okhttp/issues/2138
Issue Analytics
- State:
- Created 7 years ago
- Reactions:8
- Comments:22 (7 by maintainers)
Top Results From Across the Web
Okhttp - Multipart - how to disable Content-Length for a part?
I've tried to add an interceptor to the request (both addInterceptor and addNetworkInterceptor ) in order to remove that unwanted header. But it ......
Read more >RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1
1. If the Request-URI is encoded using the "% HEX HEX" encoding [42], the origin server MUST decode the Request-URI in order to...
Read more >Multipart Requests
OAS 3 This guide is for OpenAPI 3.0. Multipart Requests. Multipart requests combine one or more sets of data into a single body,...
Read more >POST - HTTP - MDN Web Docs
The HTTP POST method sends data to the server. The type of the body of the request is indicated by the Content-Type header....
Read more >File uploads (profile image, simple, resumable uploads)
You must provide a top-level Content-Length header that declares the length of the entire request body in bytes. · The first part of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re the only one. You should petition the owner of the server who has this limitation to fix their server so we don’t have to fix our client.
@code-n-roll this might get you unstuck:
Use it like this: