Getting “411 Length Required” after a PUT request from HTTP Client

前端 未结 1 1028
清歌不尽
清歌不尽 2021-01-17 17:52

I am working on a Java program that implements an HTTP Client. I test it sending requests to a server. GET, POST and DELETE requests work ok. For example after a POST reques

1条回答
  •  北海茫月
    2021-01-17 18:07

    Yes, the issue related to Content-Length. HTTP Error 411 means

    The server refuses to accept the request without a defined Content- Length. The client MAY repeat the request if it adds a valid Content-Length header field containing the length of the message-body in the request message.

    So when you send an empty RequestBody in POST/PUT Method then you also need to send Content-Length:0. So add this header in your request. I don't think this header will cause a problem of you added into Request Object.

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