REST client๋ฅผ ์ฌ์ฉํ๋ฉด HTTP ์์ฒญ์ ๋ณด๋ด๊ณ vs code์์ ์ง์ ์๋ต์ ๋ณผ ์ ์์ต๋๋ค.
์ฌ์ดํธ: https://marketplace.visualstudio.com/items?itemName=humao.rest-client
vs code ์์์ ์๋์ ๊ฐ์ด ๊ฐ๋จํ ์ ๋ ฅํ์๋ฉด ๋ฉ๋๋ค.
https://example.com/comments/1
ํ์ค RFC 2616์ ๋ฐ๋ผ์ request method, headers and body๋ฅผ ์ ์ ํ ์ ์์ต๋๋ค.
POST https://example.com/comments HTTP/1.1
content-type: application/json
{
"name": "sample",
"time": "Wed, 21 Oct 2015 18:27:50 GMT"
}
๊ฐ์ ํ์ผ์ ๋ง์ ์์ฒญ์ ์ ์ฅํ๊ณ ์ํ๋๋๋ก ์ฝ๊ฒ ์คํํ ์ ์์ต๋๋ค. REST Client๋ ์ธ ๊ฐ ์ด์์ ์ฐ์ ๋ #์ผ๋ก ์์ํ๋ ๋ชจ๋ ํ์ ์์ฒญ ๊ฐ์ ๊ตฌ๋ถ ๊ธฐํธ๋ก ์ธ์ ํ ์ ์์ต๋๋ค.
GET https://example.com/comments/1 HTTP/1.1
###
GET https://example.com/topics/1 HTTP/1.1
###
POST https://example.com/comments HTTP/1.1
content-type: application/json
{
"name": "sample",
"time": "Wed, 21 Oct 2015 18:27:50 GMT"
}
์ ํ ์์ญ์ ์ฒซ ๋ฒ์งธ ๋น์ด ์์ง ์์ ํ (๋๋ ์๋ฌด๊ฒ๋ ์ ํ๋์ง ์์ ๊ฒฝ์ฐ ๋ฌธ์)์ด Request Line์ ๋๋ค.
GET https://example.com/comments/1 HTTP/1.1
GET https://example.com/comments/1
https://example.com/comments/1
method ๊ฐ ์๋ต๋๋ฉด ์์ฒญ์ GET์ผ๋ก ์ฒ๋ฆฌ๋ฉ๋๋ค.
GET https://example.com/comments?page=2&pageSize=10
GET https://example.com/comments
?page=2
&pageSize=10
์ฒซ ๋ฒ์งธ ์ค์ ๋ํ Request Line ๋ฐ๋ก ๋ค์ ์ค์ Request Headers๋ก ์ฌ์ฉ๋ฉ๋๋ค.
User-Agent: rest-client
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6,zh-CN;q=0.4
Content-Type: application/json
Request Headers ๋ค์์ ๋น ์ค์ ์ถ๊ฐํ๊ณ ์ดํ์ ๋ชจ๋ ๋ด์ฉ์ Request Body๋ก ์ฒ๋ฆฌ๋ฉ๋๋ค.
POST https://example.com/comments HTTP/1.1
Content-Type: application/xml
Authorization: token xxx
<request>
<name>sample</name>
<time>Wed, 21 Oct 2015 18:27:50 GMT</time>
</request>
POST https://example.com/comments HTTP/1.1
Content-Type: application/xml
Authorization: token xxx
< C:\Users\Default\Desktop\demo.xml
POST https://example.com/comments HTTP/1.1
Content-Type: application/xml
Authorization: token xxx
< ./demo.xml
POST https://api.example.com/user/upload
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="text"
title
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="image"; filename="1.png"
Content-Type: image/png
< ./1.png
------WebKitFormBoundary7MA4YWxkTrZu0gW--