1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
---
title: PUT
slug: Web/HTTP/Methods/PUT
tags:
- HTTP
- HTTP method
- Reference
- Request method
translation_of: Web/HTTP/Methods/PUT
---
<div>{{HTTPSidebar}}</div>
<p><strong>HTTP <code>PUT</code> 메서드</strong>는 요청 페이로드를 사용해 새로운 리소스를 생성하거나, 대상 리소스를 나타내는 데이터를 대체합니다.</p>
<p><code>PUT</code>과 {{httpmethod("POST")}}의 차이는 {{glossary("idempotent", "멱등성")}}으로, <code>PUT</code>은 멱등성을 가집니다. <code>PUT</code>은 한 번을 보내도, 여러 번을 연속으로 보내도 같은 효과를 보입니다. 즉, 부수 효과가 없습니다.</p>
<table class="properties">
<tbody>
<tr>
<th scope="row">요청에 본문 존재</th>
<td>예</td>
</tr>
<tr>
<th scope="row">성공 응답에 본문 존재</th>
<td>아니오</td>
</tr>
<tr>
<th scope="row">{{Glossary("Safe", "안전함")}}</th>
<td>아니오</td>
</tr>
<tr>
<th scope="row">{{Glossary("Idempotent", "멱등성")}}</th>
<td>예</td>
</tr>
<tr>
<th scope="row">{{Glossary("Cacheable", "캐시 가능")}}</th>
<td>아니오</td>
</tr>
<tr>
<th scope="row">HTML 양식에서 사용 가능</th>
<td>아니오</td>
</tr>
</tbody>
</table>
<h2 id="구문">구문</h2>
<pre class="syntaxbox">PUT /new.html HTTP/1.1
</pre>
<h2 id="예제">예제</h2>
<h3 id="요청">요청</h3>
<pre>PUT /new.html HTTP/1.1
Host: example.com
Content-type: text/html
Content-length: 16
<p>New File</p></pre>
<h3 id="응답">응답</h3>
<p>대상 리소스를 나타내는 데이터가 없고, PUT 요청이 성공적으로 하나를 새로 생성한 경우, 출처 서버는 반드시 {{glossary("user agent", "사용자 에이전트")}}에게 {{HTTPStatus("201")}} (<code>Created</code>) 응답을 보내 해당 사항을 알려줘야 합니다.</p>
<pre class="newpage">HTTP/1.1 201 Created
Content-Location: /new.html</pre>
<p>대상 리소스를 나타내는 데이터가 있고, 이를 요청에 포함된 자료에 준하여 성공적으로 수정했다면, 출처 서버는 반드시 {{httpstatus("200")}} (<code>OK</code>) 또는 {{httpstatus("204")}} (<code>No Content</code>) 응답을 보내 성공을 알려줘야 합니다.</p>
<pre>HTTP/1.1 204 No Content
Content-Location: /existing.html
</pre>
<h2 id="명세">명세</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">명세</th>
<th scope="col">제목</th>
</tr>
<tr>
<td>{{RFC("7231", "PUT", "4.3.4")}}</td>
<td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td>
</tr>
</tbody>
</table>
<h2 id="브라우저_호환성">브라우저 호환성</h2>
<p>{{Compat("http.methods.PUT")}}</p>
<h2 id="같이_보기">같이 보기</h2>
<ul>
<li>{{HTTPStatus("201")}}</li>
<li>{{HTTPStatus("204")}}</li>
</ul>
|