{"id":9981,"date":"2021-07-28T16:38:40","date_gmt":"2021-07-28T11:08:40","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=9981"},"modified":"2024-06-06T19:17:35","modified_gmt":"2024-06-06T13:47:35","slug":"http-methods","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/http-methods\/","title":{"rendered":"HTTP METHODS"},"content":{"rendered":"\n<p>HTTP methods indicate the desired action to be performed on the identified source. The HTTP defines certain methods. Any client can use those methods and therefore the server which may be configured to support any combination. If any method is intermediate, it will be treated as an unsafe and non-idempotent method.&nbsp; Few <a href=\"https:\/\/www.h2kinfosys.com\/blog\/http-methods\/\" class=\"rank-math-link\">http methods<\/a> like:&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>GET,&nbsp;<\/li>\n\n\n\n<li>POST,&nbsp;<\/li>\n\n\n\n<li>PUT,&nbsp;<\/li>\n\n\n\n<li>DELETE,&nbsp;<\/li>\n\n\n\n<li>CONNECT,&nbsp;<\/li>\n\n\n\n<li>TRACE&nbsp;<\/li>\n<\/ul>\n\n\n\n<p>methods are explained here.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>GET<\/strong><\/li>\n<\/ol>\n\n\n\n<p>A GET request fetches the data from a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Web_server\" class=\"rank-math-link\" rel=\"nofollow noopener\" target=\"_blank\">web server<\/a> by specifying elements in the URL part of the request. This is considered as main method for document retrieval. We can use this method very easily. This method contains URL(Link). For example<\/p>\n\n\n\n<p>We can type in URL, any website name that will do get request task and the server will respond by opening the webpage.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/BJfmkuJvH6B1v6Php0wWnoBw7G2QLPc5PB9DfnhVdelGW43Aj7u5dCGk4ght0sqo3kL-Ggi1a_JZjEeg56-Onseu05OBkFetDK8QVpdODxglJ0KB-MvnbqxmUPFStsr5S2na8vU\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>By using GET request we can read server side data, retrieve server side data or update server side data.<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li><strong>POST<\/strong> Method<\/li>\n<\/ol>\n\n\n\n<p>The POST method is used when we want to send the data to the server like we want to retrieve the data or update the data. In this POST body, we use URL as well as request body, for example<\/p>\n\n\n\n<p>https:\/\/example.com\/test\/demo_form.php Http\/1.1<\/p>\n\n\n\n<p>name1=value1&amp; name2=value2<\/p>\n\n\n\n<p>Here there are two parts. In the first part we enter the URL address and in the second part we have request body where we send data .<\/p>\n\n\n\n<p>The main difference between GET method and POST is, in the GET method we enter address and data all in url and request but in POST method we send data separately in the request body so that the data remains secure and hidden. Consider an example for google forms<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/GvfQjMGj8ivnordCs3fEH-fFXg646ppfblzEOUMcT13JsWOJU3SWIyFhTVOtVdEK_DUqavlCoIFlDa71I8zUU2RMUY0uU2TUEmFPeheyZvZG9riKaj61YSQvkVPVwBTwAlZ_U3c\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>When you enter all the details like name, address qualification etc and at the end when you click submit button the server will store all the data in the request body and through the help of URL address it sends the request message to the server and based on that the server provides the response.<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li><strong>PUT<\/strong> method<\/li>\n<\/ol>\n\n\n\n<p>PUT method is used to request the server to store the involved entity body at&nbsp; a location specified by a given URL. PUT puts a file or resource at a specific URL and exactly at the URL. If there is a file or resource already, PUT replaces that file or resource. If there is no file or resource the PUT creates one.<\/p>\n\n\n\n<p>Consider a sample example of HTTP PUT request and response<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PUT \/hello.htm HTTP\/1.1\n\nUser-Agent: Mozilla\/4.0 (compatible; MSIE5.01; Windows NT)\nHost: www.iitworkforce.com\nAccept-Language: en-us\nConnection: Keep-Alive\nContent-type: text\/html\nContent-Length: 182\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;html&gt;\n&lt;body&gt;\n&lt;h1&gt;Hello, World!&lt;\/h1&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Response is\nHTTP\/1.1 201 Created\nDate: Mon, 27 Jul 2009 12:28:53 GMT\nServer: Apache\/2.2.14 (Win32)\nContent-type: text\/html\nContent-length: 30\nConnection: Closed\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;html&gt;\n&lt;body&gt;\n&lt;h1&gt;The file was created.&lt;\/h1&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n\n\n\n<p>In this example, we are requesting for creating or updating the resource. Whenever PUT request is placed it will check the whether the resource is present in the server if it is not then it will update the resource. Correspondingly the server sends the response to the client machine for the request.<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li><strong>DELETE<\/strong> method<\/li>\n<\/ol>\n\n\n\n<p>The DELETE method is used to request the server to delete a file at a location specified by the given URL. The example of DELETE request and response are<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DELETE \/hello.htm HTTP\/1.1\nUser-Agent: Mozilla\/4.0 (compatible; MSIE5.01; Windows NT)\nHost: www.iitworkforce.com\nAccept-Language: en-us\nConnection: Keep-Alive\n\n\nHTTP\/1.1 200 OK\nDate: Mon, 27 Jul 2021 12:28:53 GMT\nServer: Apache\/2.2.14 (Win32)\nContent-type: text\/html\nContent-length: 30\nConnection: Closed\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;html&gt;\n&lt;body&gt;\n&lt;h1&gt;URL deleted.&lt;\/h1&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n\n\n\n<p>In this example the server will delete the mentioned file hello.htm and sends the response to the client.<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li><strong>CONNECT<\/strong> Method<\/li>\n<\/ol>\n\n\n\n<p>The CONNECT method is used by the client to connect the connection or create the network connection to a web server over HTTP methods. For example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CONNECT www.iitworkforce.com HTTP\/1.1\nUser-Agent: Mozilla\/4.0 (compatible; MSIE5.01; Windows NT)\n<\/code><\/pre>\n\n\n\n<p>When the connection is established the server response is sent back to the client.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HTTP\/1.1 200 Connection established\nDate: Mon, 27 Jul 2009 12:28:53 GMT\nServer: Apache\/2.2.14 (Win32)\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>TRACE method<\/li>\n<\/ol>\n\n\n\n<p>The TRACE method uses to echo the contents of an HTTP request back to the requester which can be used for debugging purpose at the time of development. For example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>TRACE \/ HTTP\/1.1\nHost: www.iitworkforce.com\nUser-Agent: Mozilla\/4.0 (compatible; MSIE5.01; Windows NT)\n<\/code><\/pre>\n\n\n\n<p>The server response is sent back for the above client request.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HTTP\/1.1 200 OK\nDate: Mon, 27 Jul 2009 12:28:53 GMT\nServer: Apache\/2.2.14 (Win32)\nConnection: close\nContent-Type: message\/http\nContent-Length: 39\n\nTRACE \/ HTTP\/1.1\nHost: www.tutorialspoint.com\nUser-Agent: Mozilla\/4.0 (compatible; MSIE5.01; Windows NT)\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>HTTP methods indicate the desired action to be performed on the identified source. The HTTP defines certain methods. Any client can use those methods and therefore the server which may be configured to support any combination. If any method is intermediate, it will be treated as an unsafe and non-idempotent method.&nbsp; Few http methods like:&nbsp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9986,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-9981","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-qa-tutorials"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/9981","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=9981"}],"version-history":[{"count":0,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/9981\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/9986"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=9981"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=9981"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=9981"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}