HTTP request and response

HTTP 요청과 응답

A client sends a request and the server answers with a status, headers, and a body.

···
html
<div class="n-demo"><div class="n-head"><strong>REQUEST / RESPONSE</strong><span>LIVE TRACE</span></div><div class="n-stage"><div class="req n-box mono">GET /items<br>Accept: json</div><div class="req-arrow">→</div><div class="res n-box mono"><div id="h0">HTTP/1.1 200</div><div id="h1">Content-Type: json</div><div id="h2">{ items: 3 }</div></div></div><div class="n-foot">tap to step · auto replay</div></div>
css
.n-demo{width:min(94vw,760px);height:min(88vh,324px);padding:clamp(9px,2.2vmin,18px);border:1px solid var(--line);border-radius:13px;background:var(--surface);display:flex;flex-direction:column;gap:clamp(5px,1.3vmin,10px);font:600 clamp(12px,2.4vmin,16px)/1.3 "Pretendard Variable",Pretendard,-apple-system,BlinkMacSystemFont,"Apple SD Gothic Neo",sans-serif;overflow:hidden}.n-head,.n-foot{display:flex;justify-content:space-between;align-items:center;color:var(--muted)}.n-head strong{color:var(--accent)}.n-head span,.n-foot{font-size:12px}.n-stage{flex:1;min-height:0;position:relative;display:flex;align-items:center;justify-content:center;gap:clamp(4px,1vmin,10px)}.mono{font-family:ui-monospace,SFMono-Regular,Consolas,monospace}.n-box{padding:clamp(5px,1.5vmin,11px);border:1px solid var(--line);border-radius:8px;background:var(--bg);text-align:center}.n-on{border-color:var(--accent)!important;color:var(--accent)!important;background:color-mix(in srgb,var(--accent) 12%,var(--surface))!important}.n-muted{color:var(--muted)}@media(max-width:400px){.n-head span{display:none}}.req,.res{width:43%;text-align:left}.req-arrow{color:var(--accent)}.res div{padding:4px;border-bottom:1px solid var(--line);opacity:.25}.res div:last-child{border:0}.res div.n-on{opacity:1}
js
let step=0;function advance(){for(let i=0;i<3;i++)document.getElementById('h'+i).classList.toggle('n-on',i<=step);step=(step+1)%3}
const clickTarget=document.querySelector('.n-demo');if(clickTarget&&typeof advance==='function'){advance();const timer=setInterval(advance,1050);clickTarget.addEventListener('pointerdown',()=>{clearInterval(timer);advance()})}

An HTTP request carries a method, target URI, headers, and optionally content. The response carries a status code, headers, and optional content.

The demo sends a request and fills the response in layers. Some responses have no body, so clients also need to interpret status and headers.

When to use

Inspect request method, headers, content, and response status separately when debugging an API call.

Open as page ↗