HTTP 상태 코드

HTTP status codes

응답 코드의 첫 자리가 성공, 리다이렉션, 클라이언트 오류, 서버 오류를 구분합니다.

···
html
<div class="n-demo"><div class="n-head"><strong>STATUS ROUTER</strong><span>LIVE TRACE</span></div><div class="n-stage"><div class="route-origin n-box mono">GET /item</div><div class="route-grid"><div id="r0" class="n-box">200<br>OK</div><div id="r1" class="n-box">302<br>MOVE</div><div id="r2" class="n-box">404<br>MISSING</div><div id="r3" class="n-box">503<br>UNAVAILABLE</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}}.route-origin{width:32%}.route-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:6px;width:62%}.route-grid .n-box{padding:6px 2px}
js
let step=0;function advance(){for(let i=0;i<4;i++)document.getElementById('r'+i).classList.toggle('n-on',i===step);step=(step+1)%4}
const clickTarget=document.querySelector('.n-demo');if(clickTarget&&typeof advance==='function'){advance();const timer=setInterval(advance,1050);clickTarget.addEventListener('pointerdown',()=>{clearInterval(timer);advance()})}

HTTP 상태 코드는 요청 처리 결과를 세 자리 숫자로 전달합니다. 2xx는 성공, 3xx는 이동, 4xx는 요청 쪽 문제, 5xx는 서버 쪽 문제를 나타냅니다.

데모는 같은 요청이 네 갈래 결과 중 하나로 이동하는 모습을 보여줍니다. 상태 코드만 보고 재시도하지 말고 메서드의 안전성과 실패 원인도 함께 확인해야 합니다.

언제 쓰나

클라이언트 오류 처리, 리다이렉트, 재시도 정책을 설계할 때 코드의 의미를 구분합니다.

페이지로 열기 ↗