Return HTTP 200 code to POST client?

I have a server sending a POST to me. I need to reply HTTP 200 OK. The server needs a view of "Forward!" before performing another action. It requires an HTTP 200 response.

EDIT I tried the header (), but for some reason the server is not reading it?

+4
source share
2 answers

Code 200 is the standard response to a successful request ... Even repeating an empty json line will result in a status of 200 OK.

echo json_encode(array()); 

If all you want to do is signal to the client that some process has been completed, you can simply respond to a status message or even an empty object, as shown above.

If you really want to manually send the 200 header, you can do it like this:

 header("Status: 200"); 

Make sure this header is sent before you send any to the server.

+3
source

This function call does the job: http_response_code(200);

See: http://php.net/manual/en/function.http-response-code.php

This function call can be thrown anywhere in the server code - the order of the call to this function does not matter.

0
source

All Articles