Open In App
Related Articles

HTTP | PUT

Improve Article
Improve
Save Article
Save
Like Article
Like

The HTTP PUT request method is used to create a new resource or overwrite a representation of the target resource that is known by the client. Calling this method once is similar to calling it multiple times successively as it has the same effect. Though it is idempotent, we cannot cache its response.

Syntax:

PUT /html file HTTP/1.1

Example:
REQUEST:

PUT /example.html HTTP/1.1
Host: sample.com
Content-type: text/html
Content-length: 20

<p>New File</p>

RESPONSE: If the PUT request successfully creates a new resource, then the server informs the user by sending 201(Created) response.
Output:

HTTP/1.1 201 Created
Content-Location: /example.html

If the target resource already has a representation and it is successfully modified by the request then the server must send either a 200(OK) or 204(No Content) response indicating that the response is successful.
Output:

HTTP/1.1 204 No Content
Content-Location: /newexample.html 

Supported Browsers: The browsers supported by HTTP | PUT are listed below:

  • Google Chrome 6.0+
  • Internet Explorer 9.0+
  • Firefox 4.0+
  • Apple Safari 5.0
  • Opera 11.1
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 31 Oct, 2019
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials