19.09.2017 Views

the-web-application-hackers-handbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

48 Chapter 3 n Web Application Technologies<br />

Status Codes<br />

Each HTTP response message must contain a status code in its first line, indicating<br />

<strong>the</strong> result of <strong>the</strong> request. The status codes fall into five groups, according<br />

to <strong>the</strong> code’s first digit:<br />

n 1xx — Informational.<br />

n 2xx — The request was successful.<br />

n 3xx — The client is redirected to a different resource.<br />

n 4xx — The request contains an error of some kind.<br />

n 5xx — The server encountered an error fulfilling <strong>the</strong> request.<br />

There are numerous specific status codes, many of which are used only in<br />

specialized circumstances. Here are <strong>the</strong> status codes you are most likely to<br />

encounter when attacking a <strong>web</strong> <strong>application</strong>, along with <strong>the</strong> usual reason phrase<br />

associated with <strong>the</strong>m:<br />

n 100 Continue is sent in some circumstances when a client submits a<br />

request containing a body. The response indicates that <strong>the</strong> request headers<br />

were received and that <strong>the</strong> client should continue sending <strong>the</strong> body. The<br />

server returns a second response when <strong>the</strong> request has been completed.<br />

n 200 OK indicates that <strong>the</strong> request was successful and that <strong>the</strong> response<br />

body contains <strong>the</strong> result of <strong>the</strong> request.<br />

n 201 Created is returned in response to a PUT request to indicate that <strong>the</strong><br />

request was successful.<br />

n 301 Moved Permanently redirects <strong>the</strong> browser permanently to a different<br />

URL, which is specified in <strong>the</strong> Location header. The client should use <strong>the</strong><br />

new URL in <strong>the</strong> future ra<strong>the</strong>r than <strong>the</strong> original.<br />

n 302 Found redirects <strong>the</strong> browser temporarily to a different URL, which is<br />

specified in <strong>the</strong> Location header. The client should revert to <strong>the</strong> original<br />

URL in subsequent requests.<br />

n 304 Not Modified instructs <strong>the</strong> browser to use its cached copy of <strong>the</strong><br />

requested resource. The server uses <strong>the</strong> If-Modified-Since and If-None-<br />

Match request headers to determine whe<strong>the</strong>r <strong>the</strong> client has <strong>the</strong> latest version<br />

of <strong>the</strong> resource.<br />

n 400 Bad Request indicates that <strong>the</strong> client submitted an invalid HTTP request.<br />

You will probably encounter this when you have modified a request in<br />

certain invalid ways, such as by placing a space character into <strong>the</strong> URL.<br />

n 401 Unauthorized indicates that <strong>the</strong> server requires HTTP au<strong>the</strong>ntication<br />

before <strong>the</strong> request will be granted. The WWW-Au<strong>the</strong>nticate header contains<br />

details on <strong>the</strong> type(s) of au<strong>the</strong>ntication supported.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!