HttpURLConnection GET request getting 400 Bad Request

限于喜欢 提交于 2019-11-29 11:44:53
Vineet Reynolds

The code attempts to open a connection to www.awebsite.com, but it also sends illegal/invalid values for the Host field: www.google.com. This is definitely not allowed by the HTTP specification.

You would have to correct this, to ensure that the server at www.awebsite.com receives the correct set of headers, so that it can process your request.

Obligatory link: How to use java.net.URLConnection to fire and handle HTTP requests?

DanielGibbs

It seems that in this case the HTTP 400 is being used not to signify an error in the request syntax, but a logical error as described here: HTTP 400 (bad request) for logical error, not malformed request syntax.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!