If you are talking about HttpURLConnection, you cannot do this. Once the header is set, it cannot be deleted.
Setting the header to zero or blank does not work. I tried this before in Java 5, this led to invalid HTTP headers like
Content-Type: text/html
User-Agent
Content-Length: 123
source
share