Skip to content

Instantly share code, notes, and snippets.

@cyogian
Created Aug 3, 2019
Embed
What would you like to do?
Technical Documentation Page | HTTP
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">var scrolltotop={setting:{startline:100,scrollto:0,scrollduration:1e3,fadeduration:[500,100]},controlHTML:'<img src="https://i1155.photobucket.com/albums/p559/scrolltotop/arrow44.png" />',controlattrs:{offsetx:5,offsety:5},anchorkeyword:"#top",state:{isvisible:!1,shouldvisible:!1},scrollup:function(){this.cssfixedsupport||this.$control.css({opacity:0});var t=isNaN(this.setting.scrollto)?this.setting.scrollto:parseInt(this.setting.scrollto);t="string"==typeof t&&1==jQuery("#"+t).length?jQuery("#"+t).offset().top:0,this.$body.animate({scrollTop:t},this.setting.scrollduration)},keepfixed:function(){var t=jQuery(window),o=t.scrollLeft()+t.width()-this.$control.width()-this.controlattrs.offsetx,s=t.scrollTop()+t.height()-this.$control.height()-this.controlattrs.offsety;this.$control.css({left:o+"px",top:s+"px"})},togglecontrol:function(){var t=jQuery(window).scrollTop();this.cssfixedsupport||this.keepfixed(),this.state.shouldvisible=t>=this.setting.startline?!0:!1,this.state.shouldvisible&&!this.state.isvisible?(this.$control.stop().animate({opacity:1},this.setting.fadeduration[0]),this.state.isvisible=!0):0==this.state.shouldvisible&&this.state.isvisible&&(this.$control.stop().animate({opacity:0},this.setting.fadeduration[1]),this.state.isvisible=!1)},init:function(){jQuery(document).ready(function(t){var o=scrolltotop,s=document.all;o.cssfixedsupport=!s||s&&"CSS1Compat"==document.compatMode&&window.XMLHttpRequest,o.$body=t(window.opera?"CSS1Compat"==document.compatMode?"html":"body":"html,body"),o.$control=t('<div id="topcontrol">'+o.controlHTML+"</div>").css({position:o.cssfixedsupport?"fixed":"absolute",bottom:o.controlattrs.offsety,right:o.controlattrs.offsetx,opacity:0,cursor:"pointer"}).attr({title:"Scroll to Top"}).click(function(){return o.scrollup(),!1}).appendTo("body"),document.all&&!window.XMLHttpRequest&&""!=o.$control.text()&&o.$control.css({width:o.$control.width()}),o.togglecontrol(),t('a[href="'+o.anchorkeyword+'"]').click(function(){return o.scrollup(),!1}),t(window).bind("scroll resize",function(t){o.togglecontrol()})})}};scrolltotop.init();</script>
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
<nav id="navbar">
<header>HTTP Documentation</header>
<ul>
<li><a class="nav-link" href="#Overview">Overview</a></li>
<li><a class="nav-link" href="#Parameters">Parameters</a></li>
<li><a class="nav-link" href="#Messages">Messages</a></li>
<li><a class="nav-link" href="#Requests">Requests</a></li>
<li><a class="nav-link" href="#Methods">Methods</a></li>
<li><a class="nav-link" href="#Reference">Reference</a></li>
</ul>
</nav>
<main id="main-doc">
<section class="main-section" id="Overview">
<header>Overview</header>
<article>
<p>
The Hypertext Transfer Protocol (HTTP) is an application-level protocol for distributed, collaborative, hypermedia information systems. This is the foundation for data communication for the World Wide Web (i.e. internet) since 1990. HTTP is a generic and stateless protocol which can be used for other purposes as well using extensions of its request methods, error codes, and headers.
</p>
<p>
Basically, HTTP is a TCP/IP based communication protocol, that is used to deliver data (HTML files, image files, query results, etc.) on the World Wide Web. The default port is TCP 80, but other ports can be used as well. It provides a standardized way for computers to communicate with each other. HTTP specification specifies how clients' request data will be constructed and sent to the server, and how the servers respond to these requests.
</p>
<h2>Basic Features</h2>
<p>There are three basic features that make HTTP a simple but powerful protocol:
</p>
<ul>
<li><strong>HTTP is connectionless:</strong> The HTTP client, i.e., a browser initiates an HTTP request and after a request is made, the client waits for the response. The server processes the request and sends a response back after which client disconnect the connection. So client and server knows about each other during current request and response only. Further requests are made on new connection like client and server are new to each other.</li>
<li><strong>HTTP is media independent:</strong> It means, any type of data can be sent by HTTP as long as both the client and the server know how to handle the data content. It is required for the client as well as the server to specify the content type using appropriate MIME-type.</li>
<li><strong>HTTP is stateless:</strong> As mentioned above, HTTP is connectionless and it is a direct result of HTTP being a stateless protocol. The server and client are aware of each other only during a current request. Afterwards, both of them forget about each other. Due to this nature of the protocol, neither the client nor the browser can retain information between different requests across the web pages.</li>
</ul>
<p class="note">
HTTP/1.0 uses a new connection for each request/response exchange, where as HTTP/1.1 connection may be used for one or more request/response exchanges.
</p>
<h2>Basic Architecture</h2>
<p>
The following diagram shows a very basic architecture of a web application and depicts where HTTP sits:
</p>
<div style="width: 100%; text-align: center;"><img src="https://www.tutorialspoint.com/http/images/cgiarch.gif" style="width: 100%; max-width: 300px;"></div>
<p>
The HTTP protocol is a request/response protocol based on the client/server based architecture where web browsers, robots and search engines, etc. act like HTTP clients, and the Web server acts as a server.
<h3>Client</h3>
The HTTP client sends a request to the server in the form of a request method, URI, and protocol version, followed by a MIME-like message containing request modifiers, client information, and possible body content over a TCP/IP connection.
<h3>Server</h3>
The HTTP server responds with a status line, including the message's protocol version and a success or error code, followed by a MIME-like message containing server information, entity meta information, and possible entity-body content.
</p>
</article>
</section>
<section class="main-section" id="Parameters">
<header>Parameters</header>
<article>
<p>This chapter is going to list down few of the important HTTP Protocol Parameters and their syntax the way they are used in the communication. For example, format for date, format of URL, etc. This will help you in constructing your request and response messages while writing HTTP client or server programs. You will see the complete usage of these parameters in subsequent chapters while learning the message structure for HTTP requests and responses.
</p>
<h2>HTTP Version</h2>
<p>
HTTP uses a <strong>&ltmajor&gt.&ltminor&gt</strong> numbering scheme to indicate versions of the protocol. The version of an HTTP message is indicated by an HTTP-Version field in the first line. Here is the general syntax of specifying HTTP version number:
</p>
<code>
HTTP-Version = "HTTP" "/" 1*DIGIT "." 1*DIGIT
</code>
<h3>Example</h3>
<code>
HTTP/1.0
or
HTTP/1.1
</code>
<h2>Uniform Resource Identifiers</h2>
<p>
Uniform Resource Identifiers (URI) are simply formatted, case-insensitive string containing name, location, etc. to identify a resource, for example, a website, a web service, etc. A general syntax of URI used for HTTP is as follows:
</p>
<code>
URI = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]
</code>
<p>
Here if the port is empty or not given, port 80 is assumed for HTTP and an empty abs_path is equivalent to an abs_path of "/". The characters other than those in the reserved and unsafe sets are equivalent to their ""%" HEX HEX" encoding.
</p>
<h3>Example</h3>
<p>
The following three URIs are equivalent:
</p>
<code>
http://abc.com:80/~smith/home.html
http://ABC.com/%7Esmith/home.html
http://ABC.com:/%7esmith/home.html
</code>
<h2>Date/Time Formats</h2>
<p>
All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT), without exception. HTTP applications are allowed to use any of the following three representations of date/time stamps:
</p>
<code>
Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
</code>
<h2>Character Sets</h2>
<p>
We use character sets to specify the character sets that the client prefers. Multiple character sets can be listed separated by commas. If a value is not specified, the default is the US-ASCII.
</p>
<h3>Example</h3>
<p>Following are the valid character sets:</p>
<code>
US-ASCII
or
ISO-8859-1
or
ISO-8859-7
</code>
<h2>Content Encodings</h2>
<p>
A content encoding value indicates that an encoding algorithm has been used to encode the content before passing it over the network. Content coding are primarily used to allow a document to be compressed or otherwise usefully transformed without losing the identity.
</p>
<p>
All content-coding values are case-insensitive. HTTP/1.1 uses content-coding values in the Accept-Encoding and Content-Encoding header fields which we will see in the subsequent chapters.
</p>
<h3>Example</h3>
<p>
Following are the valid encoding schemes:
</p>
<code>
Accept-encoding: gzip
or
Accept-encoding: compress
or
Accept-encoding: deflate
</code>
<h2>Media Types</h2>
<p>
HTTP uses Internet Media Types in the Content-Type and Accept header fields in order to provide open and extensible data typing and type negotiation. All the Media-type values are registered with the Internet Assigned Number Authority (IANA). The general syntax to specify media type is as follows:
</p>
<code>
media-type = type "/" subtype *( ";" parameter )
</code>
<p>
The type, subtype, and parameter attribute names are case--insensitive.
</p>
<h3>Example</h3>
<code>Accept: image/gif</code>
<h2>Language Tags</h2>
<p>
HTTP uses language tags within the Accept-Language and Content-Language fields. A language tag is composed of one or more parts: a primary language tag and a possibly empty series of subtags:
</p>
<code>
language-tag = primary-tag *( "-" subtag )
</code>
<p>
White spaces are not allowed within the tag and all tags are case- insensitive.
</p>
<h3>Example</h3>
<p>Example tags include:</p>
<code>
en, en-US, en-cockney, i-cherokee, x-pig-latin
</code>
<p>
where any two-letter primary-tag is an ISO-639 language abbreviation and any two-letter initial subtag is an ISO-3166 country code.
</p>
</article>
</section>
<section class="main-section" id="Messages">
<header>Messages</header>
<article>
<p>HTTP is based on the client-server architecture model and a stateless request/response protocol that operates by exchanging messages across a reliable TCP/IP connection.</p>
<p>An HTTP "client" is a program (Web browser or any other client) that establishes a connection to a server for the purpose of sending one or more HTTP request messages. An HTTP "server" is a program ( generally a web server like Apache Web Server or Internet Information Services IIS, etc. ) that accepts connections in order to serve HTTP requests by sending HTTP response messages.</p>
<p>
HTTP makes use of the Uniform Resource Identifier (URI) to identify a given resource and to establish a connection. Once the connection is established, HTTP messages are passed in a format similar to that used by the Internet mail [RFC5322] and the Multipurpose Internet Mail Extensions (MIME) [RFC2045]. These messages include requests from client to server and responses from server to client which will have the following format:</p>
<code>
HTTP-message = <Request> | <Response> ; HTTP/1.1 messages
</code>
<p>
HTTP requests and HTTP responses use a generic message format of RFC 822 for transferring the required data. This generic message format consists of the following four items.</p>
<code>
A Start-line
Zero or more header fields followed by CRLF
An empty line (i.e., a line with nothing preceding the CRLF)
indicating the end of the header fields
Optionally a message-body
</code>
<p>
In the following sections, we will explain each of the entities used in an HTTP message.</p>
<h2>Message Start-Line</h2>
<p>
A start-line will have the following generic syntax:</p>
<code>
start-line = Request-Line | Status-Line
</code>
<p>
We will discuss Request-Line and Status-Line while discussing HTTP Request and HTTP Response messages respectively. For now, let's see the examples of start line in case of request and response:</p>
<code>
GET /hello.htm HTTP/1.1 (This is Request-Line sent by the client)
HTTP/1.1 200 OK (This is Status-Line sent by the server)
</code>
<h2>Header Fields</h2>
<p>
HTTP header fields provide required information about the request or response, or about the object sent in the message body. There are four types of HTTP message headers:
</p>
<ul>
<li><strong>General-header:</strong> These header fields have general applicability for both request and response messages.</li>
<li><strong>Request-header:</strong> These header fields have applicability only for request messages.</li>
<li><strong>Response-header:</strong> These header fields have applicability only for response messages.</li>
<li><strong>Entity-header:</strong> These header fields define meta information about the entity-body or, if no body is present, about the resource identified by the request.</li>
</ul>
<p>
All the above mentioned headers follow the same generic format and each of the header field consists of a name followed by a colon (:) and the field value as follows:</p>
<code>
message-header = field-name ":" [ field-value ]
</code>
<p>
Following are the examples of various header fields:</p>
<code>
User-Agent: curl/7.16.3 libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3
Host: www.example.com
Accept-Language: en, mi
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
ETag: "34aa387-d-1568eb00"
Accept-Ranges: bytes
Content-Length: 51
Vary: Accept-Encoding
Content-Type: text/plain
</code>
<h2>Message Body</h2>
<p>
The message body part is optional for an HTTP message but if it is available, then it is used to carry the entity-body associated with the request or response. If entity body is associated, then usually Content-Type and Content-Length headers lines specify the nature of the body associated.
</p>
<p>
A message body is the one which carries the actual HTTP request data (including form data and uploaded, etc.) and HTTP response data from the server ( including files, images, etc.). Shown below is the simple content of a message body:
</p>
<code>
&lthtml&gt
&ltbody&gt
&lth1&gtHello, World!&lt/h1&gt
&lt/body&gt
&lt/html&gt
</code>
<p>
Next two chapters will make use of above explained concepts to prepare HTTP Requests and HTTP Responses.
</p>
</article>
</section>
<section class="main-section" id="Requests">
<header>Requests</header>
<article>
<p>
An HTTP client sends an HTTP request to a server in the form of a request message which includes following format:</p>
<code>
A Request-line
Zero or more header (General|Request|Entity) fields followed by CRLF
An empty line (i.e., a line with nothing preceding the CRLF)
indicating the end of the header fields
Optionally a message-body
</code>
<p>
The following sections explain each of the entities used in an HTTP request message.</p>
<h2>Request-Line</h2>
<p>
The Request-Line begins with a method token, followed by the Request-URI and the protocol version, and ending with CRLF. The elements are separated by space SP characters.
</p>
<code>
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
</code>
<p>
Let's discuss each of the parts mentioned in the Request-Line.</p>
<h2>Request Method</h2>
<p>
The request method indicates the method to be performed on the resource identified by the given Request-URI. The method is case-sensitive and should always be mentioned in uppercase. The following table lists all the supported methods in HTTP/1.1.</p>
<table style="width:100%; text-align: left;">
<tr>
<th style="width: 50px;">S No.</th>
<th>Description</th>
</tr>
<tr>
<td>1</td>
<td>
<h3>GET</h3>
<p>The GET method is used to retrieve information from the given server using a given URI. Requests using GET should only retrieve data and should have no other effect on the data.</p>
</td>
</tr>
<tr>
<td>2</td>
<td>
<h3>HEAD</h3>
<p>Same as GET, but it transfers the status line and the header section only.</p>
</td>
</tr>
<tr>
<td>3</td>
<td>
<h3>POST</h3>
<p>A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms.</p>
</td>
</tr>
<tr>
<td>4</td>
<td>
<h3>PUT</h3>
<p>Replaces all the current representations of the target resource with the uploaded content.</p>
</td>
</tr>
<tr>
<td>5</td>
<td>
<h3>DELETE</h3>
<p>Removes all the current representations of the target resource given by URI.</p>
</td>
</tr>
<tr>
<td>6</td>
<td>
<h3>CONNECT</h3>
<p>Establishes a tunnel to the server identified by a given URI.</p>
</td>
</tr>
<tr>
<td>7</td>
<td>
<h3>OPTIONS</h3>
<p>Describe the communication options for the target resource.</p>
</td>
</tr>
<tr>
<td>8</td>
<td>
<h3>TRACE</h3>
<p>
Performs a message loop back test along with the path to the target resource.
</p>
</td>
</tr>
</table>
<h2>Request-URI</h2>
<p>The Request-URI is a Uniform Resource Identifier and identifies the resource upon which to apply the request. Following are the most commonly used forms to specify an URI:</p>
<code>
Request-URI = "*" | absoluteURI | abs_path | authority
</code>
<table style="width:100%; text-align: left;">
<tr>
<th style="width: 40px;">S No.</th>
<th>Description</th>
</tr>
<tr>
<td>1</td>
<td>
<p>The asterisk * is used when an HTTP request does not apply to a particular resource, but to the server itself, and is only allowed when the method used does not necessarily apply to a resource. For example:</p>
<p>
<strong>
OPTIONS * HTTP/1.1
</strong>
</p>
</td>
</tr>
<tr>
<td>2</td>
<td>
<p>The absoluteURI is used when an HTTP request is being made to a proxy. The proxy is requested to forward the request or service from a valid cache, and return the response. For example:</p>
<p>
<strong>
GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1</strong>
</p>
</td>
</tr>
<tr>
<td>3</td>
<td>
<p>The most common form of Request-URI is that used to identify a resource on an origin server or gateway. For example, a client wishing to retrieve a resource directly from the origin server would create a TCP connection to port 80 of the host "www.w3.org" and send the following lines:
</p>
<strong>
GET /pub/WWW/TheProject.html HTTP/1.1
<br>
Host: www.w3.org
</strong>
</p>
<p>
Note that the absolute path cannot be empty; if none is present in the original URI, it MUST be given as "/" (the server root).</p>
</td>
</tr>
</table>
<h2>Request Header Fields</h2>
<p>We will study General-header and Entity-header in a separate chapter when we will learn HTTP header fields. For now, let's check what Request header fields are.</p>
<p>
The request-header fields allow the client to pass additional information about the request, and about the client itself, to the server. These fields act as request modifiers.Here is a list of some important Request-header fields that can be used based on the requirement:</p>
<code>
* Accept-Charset
* Accept-Encoding
* Accept-Language
* Authorization
* Expect
* From
* Host
* If-Match
* If-Modified-Since
* If-None-Match
* If-Range
* If-Unmodified-Since
* Max-Forwards
* Proxy-Authorization
* Range
* Referer
* TE
* User-Agent
</code>
<p>
You can introduce your custom fields in case you are going to write your own custom Client and Web Server.</p>
<h2>Examples of Request Message</h2>
<p>
Now let's put it all together to form an HTTP request to fetch hello.htm page from the web server running on tutorialspoint.com
</p>
<code>
GET /hello.htm HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
</code>
<p>
Here we are not sending any request data to the server because we are fetching a plain HTML page from the server. Connection is a general-header, and the rest of the headers are request headers. The following example shows how to send form data to the server using request message body:
</p>
<code>
POST /cgi-bin/process.cgi HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
licenseID=string&content=string&/paramsXML=string
</code>
<p>
Here the given URL /cgi-bin/process.cgi will be used to process the passed data and accordingly, a response will be returned. Here content-type tells the server that the passed data is a simple web form data and length will be the actual length of the data put in the message body. The following example shows how you can pass plain XML to your web server:
</p>
<code>
POST /cgi-bin/process.cgi HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
&lt?xml version="1.0" encoding="utf-8"?&gt
&ltstring xmlns="http://clearforest.com/"&gtstring&lt/string&gt
</code>
</article>
</section>
<section class="main-section" id="Methods">
<header>Methods</header>
<article>
<h2>GET Method</h2>
<p>
A GET request retrieves data from a web server by specifying parameters in the URL portion of the request. This is the main method used for document retrieval. The following example makes use of GET method to fetch hello.htm:
</p>
<code>
GET /hello.htm HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
</code>
<p>
The server response against the above GET request will be as follows:
</p>
<code>
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
ETag: "34aa387-d-1568eb00"
Vary: Authorization,Accept
Accept-Ranges: bytes
Content-Length: 88
Content-Type: text/html
Connection: Closed
&lthtml&gt
&ltbody&gt
&lth1&gtHello, World!&lt/h1&gt
&lt/body&gt
&lt/html>&gt
</code>
<h2>HEAD Method</h2>
<p>The HEAD method is functionally similar to GET, except that the server replies with a response line and headers, but no entity-body. The following example makes use of HEAD method to fetch header information about hello.htm:</p>
<code>
HEAD /hello.htm HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
</code>
<p>
The server response against the above GET request will be as follows:
</p>
<code>
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
ETag: "34aa387-d-1568eb00"
Vary: Authorization,Accept
Accept-Ranges: bytes
Content-Length: 88
Content-Type: text/html
Connection: Closed
</code>
<p>You can notice that here server the does not send any data after header.</p>
<h2>POST Method</h2>
<p>The POST method is used when you want to send some data to the server, for example, file update, form data, etc. The following example makes use of POST method to send a form data to the server, which will be processed by a process.cgi and finally a response will be returned:</p>
<code>
POST /cgi-bin/process.cgi HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Content-Type: text/xml; charset=utf-8
Content-Length: 88
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
&lt?xml version="1.0" encoding="utf-8"?&gt
&ltstring xmlns="http://clearforest.com/"&gtstring&lt/string&gt
</code>
<p>The server side script process.cgi processes the passed data and sends the following response:</p>
<code>
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
ETag: "34aa387-d-1568eb00"
Vary: Authorization,Accept
Accept-Ranges: bytes
Content-Length: 88
Content-Type: text/html
Connection: Closed
&lthtml&gt
&ltbody&gt
&lth1&gtRequest Processed Successfully&lt/h1&gt
&lt/body&gt
&lt/html&gt
</code>
<h2>PUT Method</h2>
<p>The PUT method is used to request the server to store the included entity-body at a location specified by the given URL. The following example requests the server to save the given entity-body in hello.htm at the root of the server:</p>
<code>
PUT /hello.htm HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Accept-Language: en-us
Connection: Keep-Alive
Content-type: text/html
Content-Length: 182
&lthtml&gt
&ltbody&gt
&lth1&gtHello, World!&lt/h1&gt
&lt/body&gt
&lt/html&gt
</code>
<p>
The server will store the given entity-body in hello.htm file and will send the following response back to the client:
</p>
<code>
HTTP/1.1 201 Created
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
Content-type: text/html
Content-length: 30
Connection: Closed
&lthtml&gt
&ltbody&gt
&lth1&gtThe file was created.&lt/h1&gt
&lt/body&gt
&lt/html&gt
</code>
<h2>DELETE Method</h2>
<p>The DELETE method is used to request the server to delete a file at a location specified by the given URL. The following example requests the server to delete the given file hello.htm at the root of the server:</p>
<code>
DELETE /hello.htm HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Accept-Language: en-us
Connection: Keep-Alive
</code>
<p>The server will delete the mentioned file hello.htm and will send the following response back to the client:</p>
<code>
HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
Content-type: text/html
Content-length: 30
Connection: Closed
&lthtml&gt
&ltbody&gt
&lth1&gtURL deleted.&lt/h1&gt
&lt/body&gt
&lt/html&gt
</code>
<h2>CONNECT Method</h2>
<p>The CONNECT method is used by the client to establish a network connection to a web server over HTTP. The following example requests a connection with a web server running on the host tutorialspoint.com:</p>
<code>
CONNECT www.tutorialspoint.com HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
The connection is established with the server and the following response is sent back to the client:
HTTP/1.1 200 Connection established
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
</code>
<h2>OPTIONS Method</h2>
<p>The OPTIONS method is used by the client to find out the HTTP methods and other options supported by a web server. The client can specify a URL for the OPTIONS method, or an asterisk (*) to refer to the entire server. The following example requests a list of methods supported by a web server running on tutorialspoint.com:</p>
<code>
OPTIONS * HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
</code>
<p>
The server will send an information based on the current configuration of the server, for example:
</p>
<code>
HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
Allow: GET,HEAD,POST,OPTIONS,TRACE
Content-Type: httpd/unix-directory
</code>
<h2>TRACE Method</h2>
<p>The TRACE method is used to echo the contents of an HTTP Request back to the requester which can be used for debugging purpose at the time of development. The following example shows the usage of TRACE method:</p>
<code>
TRACE / HTTP/1.1
Host: www.tutorialspoint.com
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
</code>
<p>
The server will send the following message in response to the above request:
</p>
<code>
HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
Connection: close
Content-Type: message/http
Content-Length: 39
TRACE / HTTP/1.1
Host: www.tutorialspoint.com
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
</code>
</article>
</section>
<section class="main-section" id="Reference">
<header>Reference</header>
<article><li>All the documentation in this page is taken from <a href="https://www.tutorialspoint.com/http/http_quick_guide.htm">TutorialPoint</a></li>
</article>
</section>
</main>
html,
body {
min-width: 290px;
color: #4d4e53;
background-color: #ffffff;
font-family: "Open Sans", Arial, sans-serif;
line-height: 1.5;
}
#navbar {
position: fixed;
min-width: 290px;
top: 0px;
left: 0px;
width: 300px;
height: 100%;
border-right: solid;
border-color: rgba(0, 22, 22, 0.4);
z-index: 1000;
background-color: white;
}
header {
color: black;
margin: 10px;
text-align: center;
font-size: 1.8em;
font-weight: thin;
}
#main-doc header {
text-align: left;
margin: 0px;
}
#navbar ul {
height: 88%;
padding: 0;
overflow-y: auto;
overflow-x: hidden;
}
#navbar li {
color: #4d4e53;
border-top: 1px solid;
list-style: none;
position: relative;
width: 100%;
}
#navbar a {
display: block;
padding: 10px 30px;
color: #4d4e53;
text-decoration: none;
cursor: pointer;
}
#main-doc {
position: absolute;
margin-left: 310px;
padding: 20px;
margin-bottom: 110px;
}
section article {
color: #4d4e53;
margin: 15px;
font-size: 0.96em;
}
section li {
margin: 15px 0px 0px 20px;
}
code {
display: block;
text-align: left;
white-space: pre;
position: relative;
word-break: normal;
word-wrap: normal;
line-height: 2;
background-color: #f7f7f7;
padding: 15px;
margin: 10px;
border-radius: 5px;
overflow-x: auto;
}
@media only screen and (max-width: 815px) {
/* For mobile phones: */
#navbar ul {
border: 1px solid;
height: 207px;
}
#navbar {
background-color: white;
position: absolute;
top: 0;
padding: 0;
margin: 0;
width: 100%;
max-height: 275px;
border: none;
z-index: 1;
border-bottom: 2px solid;
}
#main-doc {
position: relative;
margin-left: 0px;
margin-top: 270px;
}
}
@media only screen and (max-width: 400px) {
#main-doc {
margin-left: -10px;
}
code {
margin-left: -20px;
width: 100%;
padding: 15px;
padding-left: 10px;
padding-right: 45px;
min-width: 233px;
}
}
.note {
background-color: #ECEFF1;
border-left: 4px solid #B0BEC5;
padding-left: 4px;
max-width: 450px;
}
table, tr, td, th{
border: 1px solid black;
}
td{
padding: 5px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment