You are on page 1of 3

7/4/2017 HTTPMethods|HttpWatch

(/)

HTTP Gallery

Jump to ...

6. HTTP Methods
The HTTP method is supplied in the request line and species the operation that the client has requested. Internet Explorer will generally just
use two methods to access and interact with web sites; GET for queries that can be safely repeated and POST for operations that may have side
eects (e.g. ordering a book from an on-line store). For details of other HTTP methods refer to the HTTP 1.1 specication
(http://www.w3.org/Protocols/rfc2616/rfc2616.html).

6.1 The GET method


The GET method is used to retrieve information from a specied URI and is assumed to be a safe, repeatable operation by browsers, caches and
other HTTP aware components. This means that the operation must have no side eects and GET requests can be re-issued without worrying
about the consequences.

For example, displaying the balance of a bank account has no eect on the account and can be safely repeated. In fact, Internet Explorer will
allow a user to refresh a page that resulted from a GET, without displaying any kind of warning. Other HTTP aware components such as proxies
may automatically retry GET requests if they encounter a temporary network connection problem.

One downside of GET requests is that they can only supply data in the form of parameters encoded in the URI (known as a Query String) or as
cookies in the cookie request header. Therefore, GET cannot be used for uploading les or other operations that require large amounts of data
to be sent to the server.

6.2 The POST method


The POST method is used for operations that have side eects and cannot be safely repeated. For example, transferring money from one bank
account to another has side eects and should not be repeated without explicit approval by the user. If you try to refresh a page in Internet
Explorer that resulted from a POST, it displays the following message to warn you that there may be side eects:

For banking, and other transactional web applications, the best approach is to use a POST when the user submits a change and then use a 302
redirection to change to a GET that displays the result of the action (e.g. the new account balance). The user can then safely refresh the resulting
page without being presented with the retry dialog shown above. For more details on the POST/302 technique see 7. Redirection
(../redirection/).

The POST request message has a content body that is normally used to send parameters and data. Unlike using the request URI or cookies,
there is no upper limit on the amount of data that can be sent and POSTmust be used if les or other variable length data has to be sent to the
server.

https://www.httpwatch.com/httpgallery/methods/ 1/3
7/4/2017 HTTPMethods|HttpWatch
If you are working with Microsoft's Internet Information Server (IIS) (e.g. running the samples in this HTTP Gallery) you may notice that it returns
two status codes in its response for a POST request. The rst is 100 Continue to indicate that it has successfully received the POST request and
the second is 200 OK after the request has been processed.

Example 6a - Using GET


Adding two numbers is a safe repeatable operation. Use the Add button and try refreshing the resulting page:

2 + 12 =

ADD REFRESH THIS PAGE

Example 6b - Using POST


Modifying a bank account has side eects and should not be automatically repeated. Use the Submit button and try refreshing the resulting
page (this example uses cookies to store the account balance):

Account Balance = $1000

Amount to debit: $ 10 SUBMIT

REFRESH THIS PAGE

Example 6c - Uploading a le with POST


Files can be uploaded using the content of the POST request message. Use the Upload button to send le. (Any le up to 10 MB that takes
less than 2 minutes to upload will work. It will not be examined or stored. The page will just display its size)

Last Uploaded File:

File name:

File size (bytes):

File type:

File to upload: Seleccionararchivo No sivo

SUBMIT

Using HttpWatch with Example 6a - 6c

To view the HTTP methods discussed on this page:

1. Open HttpWatch by right clicking on the web page and selecting HttpWatch from the context menu

2. Click on Record to start logging requests in HttpWatch

3. Try using each of the examples above

4. The submitted form values can be viewed in the rst sample by looking at the Query String tab and by looking at the POST Data
tab for the others.

https://www.httpwatch.com/httpgallery/methods/ 2/3
7/4/2017 HTTPMethods|HttpWatch

<5. CACHING (../CACHING/) 7. REDIRECTION> (../REDIRECTION/)

Ready to get started?

TRY FOR FREE

(/DOWNLOAD/)
BUY NOW (/BUY/)

HttpWatch
Features (/features/httpdebugger.aspx)
Compare Editions (/editions.aspx)
New in Version 10.x (/newin10x.aspx)
Download (/download/)
Pricing (/buy/)

Our Customers
Who is using it? (/#customers)
What are they saying? (/#quotes)

Learning & Documentation


HttpWatch Blog (http://blog.httpwatch.com)
HTTP Gallery (/httpgallery/)
HttpWatch Help (http://help.httpwatch.com)
HttpWatch Automation Reference (http://apihelp.httpwatch.com)

Support
Technical Support (/support/)
About Us (/company/)
Contact Us (/company/)
Blog (http://blog.httpwatch.com)
Twitter (https://twitter.com/httpwatch)

Search (/search/) Terms & Conditions (/company/terms.aspx) Privacy Policy (/company/privacy_policy.aspx) Copyright (/company/copyright.aspx)

Copyright 2017 Neumetrix Limited (/)

https://www.httpwatch.com/httpgallery/methods/ 3/3

You might also like