HTTP status code 200 “OK” is a success status code indicating that the server has successfully processed the client’s request and returned the expected response. This is one of the most common HTTP status codes, usually meaning everything is normal and the request has been fulfilled.
The meaning of the 200 OK status code may vary depending on the request method:
- GET Request: The server successfully returns the requested resource, and the response body contains the content of that resource.
- HEAD Request: The response does not contain a message body, but the response headers are the same as those of a GET request, which can be used to confirm the resource’s existence and last modification time.
- POST Request: The request has been processed normally, and the response body may contain the result of the processing or a newly created resource.
- PUT or PATCH Request: The requested resource has been successfully modified.
- DELETE Request: The requested resource has been successfully deleted.
For example, when a client requests a webpage using the GET method, if the webpage exists on the server and the request is accepted, the server will return status code 200, along with the content of the webpage in the response body.
HTTP status code 200 is typically sent along with response headers and the response body. The response headers contain metadata about the response, such as Content-Type and Content-Length, while the response body contains the actual data, such as an HTML document, an image, or JSON data.
Here is a simple example of an HTTP response that includes status code 200 OK:
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 12345
Last-Modified: Wed, 21 Oct 2015 14:48:00 GMT
<html>
<head>
<title>Example Web Page</title>
</head>
<body>
<p>This is an example web page.</p>
</body>
</html>
In this example, the status code 200 indicates that the request was successful, the response headers provide additional information about the response, and the response body contains the content of the HTML document.