{"id":268,"date":"2014-09-01T11:15:46","date_gmt":"2014-09-01T11:15:46","guid":{"rendered":"http:\/\/mairwa.com\/wordpress\/?p=268"},"modified":"2014-09-01T11:15:46","modified_gmt":"2014-09-01T11:15:46","slug":"http-request-methods-get-and-post","status":"publish","type":"post","link":"http:\/\/mairwa.com\/wordpress\/?p=268","title":{"rendered":"HTTP Request Methods: GET and POST"},"content":{"rendered":"<p>Two HTTP Request Methods: GET and POST<\/p>\n<p>Two commonly used methods for a request-response between a client and server are: GET and POST.<\/p>\n<ul>\n<li><b>GET<\/b> &#8211; Requests data from a specified resource<\/li>\n<li><b>POST<\/b> &#8211; Submits data to be processed to a specified resource<\/li>\n<\/ul>\n<div align=\"center\">\n<hr align=\"center\" noshade=\"noshade\" size=\"1\" width=\"100%\" \/>\n<\/div>\n<p>The GET Method<\/p>\n<p><b>Note that query strings (name\/value pairs) is sent in the URL of a GET request:<\/b><\/p>\n<p>\/test\/demo_form.asp<b>?name1=value1&amp;name2=value2<\/b><\/p>\n<p><b>Some other notes on GET requests:<\/b><\/p>\n<ul>\n<li>GET requests can be cached<\/li>\n<li>GET requests remain in the browser history<\/li>\n<li>GET requests can be bookmarked<\/li>\n<li>GET requests should never be used when dealing with sensitive data<\/li>\n<li>GET requests have length restrictions<\/li>\n<li>GET requests should be used only to retrieve data<\/li>\n<\/ul>\n<div align=\"center\">\n<hr align=\"center\" noshade=\"noshade\" size=\"1\" width=\"100%\" \/>\n<\/div>\n<p>The POST Method<\/p>\n<p><b>Note that query strings (name\/value pairs) is sent in the HTTP message body of a POST request:<\/b><\/p>\n<p>POST \/test\/demo_form.asp HTTP\/1.1<br \/>\nHost: w3schools.com<br \/>\n<b>name1=value1&amp;name2=value2<\/b><\/p>\n<p><b>Some other notes on POST requests:<\/b><\/p>\n<ul>\n<li>POST requests are never cached<\/li>\n<li>POST requests do not remain in the browser history<\/li>\n<li>POST requests cannot be bookmarked<\/li>\n<li>POST requests have no restrictions on data length<\/li>\n<\/ul>\n<p>Compare GET vs. POST<\/p>\n<p>The following table compares the two HTTP methods: GET and POST.<\/p>\n<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"30%\">\n<p align=\"center\"><b>\u00a0<\/b><\/p>\n<\/td>\n<td width=\"35%\">\n<p align=\"center\"><b>GET<\/b><\/p>\n<\/td>\n<td>\n<p align=\"center\"><b>POST<\/b><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>BACK button\/Reload<\/td>\n<td>Harmless<\/td>\n<td>Data will be re-submitted (the browser should alert the user that the data are about to be re-submitted)<\/td>\n<\/tr>\n<tr>\n<td>Bookmarked<\/td>\n<td>Can be bookmarked<\/td>\n<td>Cannot be bookmarked<\/td>\n<\/tr>\n<tr>\n<td>Cached<\/td>\n<td>Can be cached<\/td>\n<td>Not cached<\/td>\n<\/tr>\n<tr>\n<td>Encoding type<\/td>\n<td>application\/x-www-form-urlencoded<\/td>\n<td>application\/x-www-form-urlencoded or multipart\/form-data. Use multipart encoding for binary data<\/td>\n<\/tr>\n<tr>\n<td>History<\/td>\n<td>Parameters remain in browser history<\/td>\n<td>Parameters are not saved in browser history<\/td>\n<\/tr>\n<tr>\n<td>Restrictions on data length<\/td>\n<td>Yes, when sending data, the GET method adds the data to the URL; and the length of a URL is limited (maximum URL length is 2048 characters)<\/td>\n<td>No restrictions<\/td>\n<\/tr>\n<tr>\n<td>Restrictions on data type<\/td>\n<td>Only ASCII characters allowed<\/td>\n<td>No restrictions. Binary data is also allowed<\/td>\n<\/tr>\n<tr>\n<td>Security<\/td>\n<td>GET is less secure compared to POST because data sent is part of the URLNever use GET when sending passwords or other sensitive information!<\/td>\n<td>POST is a little safer than GET because the parameters are not stored in browser history or in web server logs<\/td>\n<\/tr>\n<tr>\n<td>Visibility<\/td>\n<td>Data is visible to everyone in the URL<\/td>\n<td>Data is not displayed in the URL<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#8212;Below hyper link for more detail about GET and POST &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>http:\/\/www.sitepoint.com\/key-differences-post\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">Two HTTP Request Methods: GET and POST Two commonly used methods for a request-response between a client and server are: GET and POST. GET &#8211; Requests data from a specified resource POST &#8211; Submits data to be processed to a specified resource The GET Method Note that query strings (name\/value pairs) is sent in the URL of a GET request:&hellip; <a href=\"http:\/\/mairwa.com\/wordpress\/?p=268\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,9],"tags":[],"class_list":["post-268","post","type-post","status-publish","format-standard","hentry","category-c-vb","category-jquery","xfolkentry"],"_links":{"self":[{"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=268"}],"version-history":[{"count":0,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/268\/revisions"}],"wp:attachment":[{"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=268"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}