How to modify the header of a HttpUrlConnection

前端 未结 3 518
慢半拍i
慢半拍i 2020-11-27 20:44

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

相关标签:
3条回答
  • 2020-11-27 21:27

    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.

    0 讨论(0)
  • 2020-11-27 21:35

    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.

    0 讨论(0)
  • 2020-11-27 21:41

    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.

    0 讨论(0)
提交回复
热议问题