Ethical Hacking
Learn ARP Poisoning with Examples
In this tutorial we will Learn - What is IP & Mac Address What is Address Resolution Protocol...
PUT method is used to update resource available on the server. Typically, it replaces whatever exists at the target URL with something else. You can use it to make a new resource or overwrite an existing one. PUT requests that the enclosed entity must be stored under the supplied requested URI (Uniform Resource Identifier).
In this tutorial, you will learn:
POST is a method that is supported by HTTP and
depicts that a web server accepts the data included in the body of the message, which is requested. POST is often used by World Wide Web to send user generated data to the web server or when you upload file.
Here is the webserver example of a PUT method:
HTTP PUT http://www.google.com/users/234
HTTP PUT http://www.google.com/users/234/accounts/567
Request
PUT /new.html HTTP/1.1 Host: example.com Content-type: text/html Content-length: 20 <p>New File</p>
Responses
If the target resource having current representation and is modified with the state of the enclosed representation, then the server should send two responses. The first response code is 200 (OK), and the second response code is 204 (No Content).
If the target resource does not have any representation, then the server should inform the user by sending a 201 code (Created) response.
HTTP/1.1 201 Created Content-Location: /new.html
Here is an example of POST method:
HTTP POST http://www.google.com/users
HTTP POST http://www.google.com/users/234/accounts
A form using the default application/x-www-form-urlencoded content type:
POST /test HTTP/1.1 Host: abc.example Content-Type: application/x-www-form-urlencoded Content-Length: 40 field1=value1&field2=value2
Here is the important difference between PUT and POST method:
PUT | POST |
This method is idempotent. | This method is not idempotent. |
PUT method is call when you have to modify a single resource, which is already a part of resource collection. | POST method is call when you have to add a child resource under resources collection. |
RFC-2616 depicts that the PUT method sends a request for an enclosed entity stored in the supplied request URI. | This method requests the server to accept the entity which is enclosed in the request. |
PUT method syntax is PUT /questions/{question-id} | POST method syntax is POST /questions |
PUT method answer can be cached. | You cannot cache PUT method responses. |
PUT /vi/juice/orders/1234 indicates that you are updating a resource which is identified by "1234". | POST /vi/juice/orders indicates that you are creating a new resource and return an identifier to describe the resource. |
If you send the same request multiple times, the result will remain the same. | If you send the same POST request more than one time, you will receive different results. |
PUT works as specific. | POST work as abstract. |
We use UPDATE query in PUT. | We use create query in POST. |
In PUT method, the client decides which URI resource should have. | In POST method, the server decides which URI resource should have. |
Here are the steps to test API with PUT requests:
Step 1) Update resources with PUT request.
Step 2) Use GET method for resource. If the PUT request success, you will receive new data. This method will fail if the supplied data in the request is invalid. Therefore, it will not update anything.
Here are the steps to test API with POST requests:
Step 1) Create a resource using POST request and make sure that it returns 200 status code.
Step 2) Make a GET request for that resource and save the data in the correct format.
Step 3) You have to add tests which ensure POST requests fail with incorrect data.
Here are pros/benefits of using PUT method:
Here are pros/benefits of using POST method:
In this tutorial we will Learn - What is IP & Mac Address What is Address Resolution Protocol...
Skills allow you to achieve your desired goals within the available time and resources. As a...
Ethical hacking is identifying weaknesses in computer systems or networks to exploit its...
Information plays a vital role in the running of business, organizations, military operations,...
A computer system threat is anything that leads to loss or corruption of data or physical damage...
Following are frequently asked questions in interviews for freshers as well as experienced cyber...