Can Java omit sending some headers in HTTP requests?
http, http-headers, java, java-me, optimization
Solution
If you are talking about HttpURLConnection, you can't do it. Once the header is set, it can't be removed.
Setting header to null or empty doesn't work. I tried this before on Java 5, it resulted invalid HTTP headers, like
Content-Type: text/html
User-Agent
Content-Length: 123
Problem
I'm using the HttpConnection class in Java to send HTTP requests. How do I omit unwanted HTTP headers? like: - User-Agent - Accept - Accept-Language - Accept-Encoding - Accept-Charset - Keep-Alive - Connection - Referer - If-Modified-Since