Response (Response) in HTTP

After receiving and interpreting a request message, a Server sends a response signal with an HTTP response message.

  1. A status line (Status-Line)
  2. No more or more Header (General | Response | Entity) fields followed by CRLF.
  3. A blank line (for example, a line that has nothing before CRLF) indicates the end of the Header fields.
  4. An informative body part.

The following areas explain the usage of each object in an HTTP response message.

Status line

A status line includes the protocol version followed by a numeric encoding and its associated text.

 Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF 

HTTP version

A server supporting HTTP / 1.1 version will return version information as follows:

 HTTP-Version = HTTP / 1.1 

Encrypt status

The Status-Code element is a 3-character integer, in which the first character of the status encoding defines the response type and the last two characters do not have any sorting role. There are 5 values ​​of the first character:

STONE and description1 1xx: Information

It means that the request has been received and the process is continuing.

2 2xx: Successful

It means that the activity has been received, understood, and successfully accepted.

3 3xx: Redirection

It means that the operation must be done to fulfill the request.

4 4xx: Client error

It means that the request contains an incorrect or not implemented syntax.

5 5xx: Server Error

It means that Server failed with making a request that looks like it looks feasible.

HTTP status encoding is scalable and HTTP applications are not required to understand the meaning of all registered status codes. A list of all status codes has been provided in a separate chapter for your reference.

Feedback Header fields

We will learn General-Header and Entity-Header in a separate chapter when we will learn about Header fields. Now, let's find out what feedback Header fields are:

The Feedback Header fields allow the Server to transmit additional information about responses that cannot be placed in the Status-Line line. These header fields provide information about the server and remote access to the source identified by the Request-URI.

Accept-Ranges

Age

ETag

Location

Proxy-Authenticate

Retry-After

Server

Vary

WWW-Authenticate

You can create your own fields in case you are writing Client and Server for yourself.

Examples of Feedback Notifications

Now we put all of the above together to create an HTTP response for a request to instruct the hello.jsp page from the Server running on tutorialspoint.com.

HTTP/1.1 200 OK Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache/2.2.14 (Win32) Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT Content-Length: 88 Content-Type: text/html Connection: Closed 

 

 Hello, World! 

The following example shows an HTTP response message that displays the error status when the Server cannot find the requested page:

HTTP/1.1 404 Not Found Date: Sun, 18 Oct 2012 10:36:20 GMT Server: Apache/2.2.14 (Win32) Content-Length: 230 Connection: Closed Content-Type: text/html; charset=iso-8859-1
 404 Not Found 

 

 Not Found 
 The requested URL /t.html was not found on this server. 

Next is an example of an HTTP response message indicating the error state when the Server enters a wrong HTTP version in the HTTP request provided:

HTTP/1.1 400 Bad Request Date: Sun, 18 Oct 2012 10:36:20 GMT Server: Apache/2.2.14 (Win32) Content-Length: 230 Content-Type: text/html; charset=iso-8859-1 Connection: Closed 
 400 Bad Request 

 

 Bad Request 
 Your browser sent a request that this server could not understand. 
 The request line contained invalid characters following the protocol string. 

According to Tutorialspoint

Previous post: Request (HTTP) in HTTP

Next lesson: Method in HTTP

5 ★ | 1 Vote

May be interested

  • Parameters in HTTPParameters in HTTP
    this chapter lists some of the http protocol parameters and their syntax by which they are used in communication.
  • How HTTP worksHow HTTP works
    hypertext transfer protocol (http) provides a network protocol standard that web browsers and servers use to communicate. you see http every day because when you visit a website, the protocol is written right in the url.
  • 5 ways to improve website speed with HTTP / 25 ways to improve website speed with HTTP / 2
    hypertext transfer protocol version 2 (hypertext transfer protocol version 2) or http / 2 is the latest http standard. updates to this protocol will improve the speed, performance and security of web traffic.
  • How to fix 'The 504 Gateway Timeout' errorHow to fix 'The 504 Gateway Timeout' error
    'the 504 gateway timeout' error is an http status code that appears when there is no prompt response from the server being accessed while downloading a website or making another request from the browser. in other words, 504 errors often appear when a computer or a website does not respond within the specified time.
  • Web Module in Node.jsWeb Module in Node.js
    web server is a software application that can handle http requests sent by http client (for example, a web browser) and return a web page in response to the client. web server often sends html documents next to images as well as style sheets and javascript segments.
  • Full list of HTTP status codes, HTTP Status CodeFull list of HTTP status codes, HTTP Status Code
    the http status line is the term given to the http status code (real code) when accompanied by the 'http reason phrase' - the term for the reason (short description).
  • MQTT and HTTP: Which protocol is better in the IoT era?MQTT and HTTP: Which protocol is better in the IoT era?
    the hypertext transfer protocol (http) has always been the most popular communication tool between client and web server. but is it still suitable for the internet of things era?
  • Example of Message in HTTPExample of Message in HTTP
    some examples of message in http make it easier for users to visualize.
  • What is HTTP Authentication? 5 Stages of HTTP AuthenticationWhat is HTTP Authentication? 5 Stages of HTTP Authentication
    http authentication is a security mechanism that helps verify the identity of users when they access web resources.
  • How to Execute HTTP POST Requests in AndroidHow to Execute HTTP POST Requests in Android
    http post is part of a deprecated http classes like org.apache.http and androidhttpclient as of android 5.1.https://developer.android.com/about/versions/android-5.1.html#http migrate your code to the httpurlconnection classes which...