Sending Request with Close Connection Header

The "Connection: close" HTTP header informs the server that the client wants to close the connection after completing the HTTP transaction. The server decides whether to close the connection after the request or not. In this Connection Close header example, we send a GET request to the ReqBin echo URL with the "Connection: close" HTTP header. Click Send to execute the Close Connection example online and see the results.
Sending Request with Close Connection Header Send
GET /echo HTTP/1.1
Host: reqbin.com
Connection: close

Updated: Viewed: 25260 times

What are HTTP Headers?

An HTTP request or response consists of HTTP headers and an HTTP body. HTTP headers contain a case-insensitive name, a colon (:), and a header value. A header field comprises a case-insensitive name followed by a colon (':') and its value (spaces between name and value are ignored). The server uses HTTP headers to send data type information and size in the response body, compression method used, caching directives, and cross-origin resource sharing restrictions (CORS).

What is an HTTP connection header?

HTTP Connection headers are general-purpose headers that allow the sender or client to specify the parameters required for that particular connection. You can send or receive multiple HTTP requests and responses using a single TCP connection instead of opening a new connection for each request. HTTP Connection also controls whether the network remains open or closed after completing the current transaction.

Close Connection Header Syntax

The following is the syntax of the Closed Connection header:

HTTP Connection Close Syntax
Connection: close

Close Connection Example

The following is an example of sending a GET request with a Closed Connection header:

Close Connection Example
GET /echo HTTP/1.1
Host: reqbin.com
Connection: close

Server response to our request:

Server Response Example
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Connection: close

See also

Generate Code Snippets for Close Connection Example

Convert your Close Connection request to the PHP, JavaScript/AJAX, Node.js, Curl/Bash, Python, Java, C#/.NET code snippets using the ReqBin code generator.