Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. HTTP
  3. Reference
  4. Request methods
  5. PUT

PUT request method

ThePUT HTTP method creates a new resource or replaces a representation of the target resource with the requestcontent.

The difference betweenPUT andPOST is thatPUT isidempotent: calling it once is no different from calling it several times successively (there are noside effects).

Request has bodyYes
Successful response has bodyMay
SafeNo
IdempotentYes
CacheableNo
Allowed inHTML formsNo

Syntax

http
PUT <request-target>["?"<query>] HTTP/1.1
<request-target>

Identifies the target resource of the request when combined with the information provided in theHost header.This is an absolute path (e.g.,/path/to/file.html) in requests to an origin server, and an absolute URL in requests to proxies (e.g.,http://www.example.com/path/to/file.html).

<query>Optional

An optional query component preceded by a question-mark?.Often used to carry identifying information in the form ofkey=value pairs.

Examples

Successfully creating a resource

The followingPUT request asks to create a resource atexample.com/new.html with the content<p>New File</p>:

http
PUT /new.html HTTP/1.1Host: example.comContent-type: text/htmlContent-length: 16<p>New File</p>

If the target resourcedoes not have a current representation and thePUT request successfully creates one, then the origin server must send a201 Created response:

http
HTTP/1.1 201 CreatedContent-Location: /new.html

If the target resourcedoes have a current representation and that representation is successfully modified with the state in the request, the origin server must send either a200 OK or a204 No Content to indicate successful completion of the request:

http
HTTP/1.1 204 No ContentContent-Location: /existing.html

Specifications

Specification
HTTP Semantics
# PUT

Browser compatibility

The browser doesn't use thePUT method for user-initiated actions, so "browser compatibility" doesn't apply.Developers can set this request method usingfetch().

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp