Im trying to improve the Java Html Document a little but i\'m running into problems with the HttpUrlConntion
. One thing is that some servers block a request if
I solved my problem. We can just send the header to application/json and pass the body as a json object. That simply solves the issue.
If you use Apache HttpClient to manage your programmatic HTTP connectivity you get an extremely useful API which makes creating connections (and optional automatic re-connecting on fail), setting Headers, posts vs gets, handy methods for retrieving the returned content and much much more.
Open the URL
with URL.openConnection
. Optionally cast to HttpURLConnection
. Call URLConnection.setRequestProperty
/addRequestProperty
.
The default User-Agent header value is set from the "http.agent"
system property. The PlugIn and WebStart allow you to set this property.