I am talking to a file upload service that accepts post data, not form data. By default, java's HttpURLConnection
sets the Content-Type
header to application/x-www-form-urlencoded
. this is obviously wrong if i'm posting pure data.
I (the client) don't know the content type. I don't want the Content-Type
header set at all. the service has a feature where it will guess at the content type (based on the file name, reading some data from the file, etc).
How do I unset a header? There's no remove header, and setting it to null
doesn't change the value and setting it to the empty string results in the header being set with no value.
I haven't tested this approach but you can try this:
Extend HttpURLConnection and try by overriding its getContentHandler() and setContentHandler(...) methods. Most probably this should work as, you will take a look at code of getContentHandler().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With