5

What is the difference between HTTP 100 and 200status code?

Are they the same?

I was told that 200 is the standard code when the HTTP request is successful without any errors whatsoever.

Is that right?

What about this 100 code? I have found different explanations on this status code. could somebody explain that using some real world example please?

Because right now I don't know the difference and both seem to be the same to me.

aspentistar
  • 97
  • 1
  • 5

2 Answers2

6

Let's me give you an example:

You’re sending a large object to the server using a PUT request, you may include a Expect header like this:

PUT /media/file.mp4  HTTP/1.1
Host: api.example.org
Content-Length: 1073741824
Expect: 100-continue

This tells the server that it should respond with a 100 Continue status code if the server is going to be able to accept the request:

HTTP/1.1 100 Continue

When the client receives this, it tells the client the server will accept the request, and it may start sending the request body.

The big benefit here is that if there’s a problem with the request, a server can immediately respond with an error before the client starts sending the request body.

A simple use-case is that a server might first require authentication using 401 Unauthorized, or it might know in advance that the Content-Type that the client wants to send to the server is not something the server will want to accept.

Mainly cited from :

https://evertpot.com/http/100-continue/

https://www.rfc-editor.org/rfc/rfc7231#section-5.1.1

Community
  • 1
  • 1
Jayhello
  • 5,931
  • 3
  • 49
  • 56
3

From: http://www.rfc-editor.org/rfc/rfc7231.txt

6.2.1. 100 Continue

The 100 (Continue) status code indicates that the initial part of a request has been received and has not yet been rejected by the server. The server intends to send a final response after the request has been fully received and acted upon.

When the request contains an Expect header field that includes a 100-continue expectation, the 100 response indicates that the server wishes to receive the request payload body, as described in Section 5.1.1. The client ought to continue sending the request and discard the 100 response.

If the request did not contain an Expect header field containing the 100-continue expectation, the client can simply discard this interim response.

(edited, thank you Julian for noticing :)