Is an HTTP PUT request required to include a body?

后端 未结 5 461
失恋的感觉
失恋的感觉 2020-12-07 20:03

I\'m having trouble finding a definite specification of this in the standard. I have an HTTP client that\'s not including a Content-Length: 0 header when doing

5条回答
  •  悲哀的现实
    2020-12-07 20:16

    A body is not required by the IETF standard, though the content-length should be 0 if there's no body. Use the method that's appropriate for what you're doing. If you were to put it into code, given

    int x;
    int f(){ return x; }
    

    and a remote variable called r.

    A post is equivalent to

    r=f();
    

    A put is equivalent to

    r=x;
    

    and a get is equivalent to

    x=r;
    

提交回复
热议问题