0
votes

I'm writing a simple socket program that implements an HTTP server that can handle POST requests. I want my server to send a 200 OK response after receiving a POST request. My problem is, I don't know what the payload of the 200 OK response should be like. According to https://www.rfc-editor.org/rfc/rfc7231#section-6.3.1, the body of 200 OK response to a POST request should be:

a representation of the status of, or results obtained from, the action

Could anyone explain what this sentence means? What is a representation of the status of the action? What should I include in the body of the response?

2

2 Answers

0
votes

POST generally means to create something, so you could send a response containing data from the newly created resource. Alternatively you could respond with 201 and no body.

0
votes

It fully depends on the context. If it is some REST application the HTTP response might return a JSON with the id of a newly created resource. If it is some HTML form upload it will instead likely return a HTML page which somehow reflects the result of the upload, like the new status of the shopping card with the item added, a newly created blog post or whatever makes sense in the specific context.