Java Reference
In-Depth Information
<html>
<head>
<title>
A Sample HTML file
</title>
</head>
<body>
The rest of the document goes here
</body>
</html>
The first line indicates the protocol the server is using ( HTTP/1.1 ), followed by a re‐
sponse code. 200 OK is the most common response code, indicating that the request was
successful. The other header lines identify the date the request was made in the server's
time frame, the server software (Apache), a promise that the server will close the con‐
nection when it's finished sending, the MIME media type, and the length of the docu‐
ment delivered (not counting this header)—in this case, 107 bytes.
Table 6-1 lists the standard and experimental response codes you're most likely to en‐
counter, minus a few used by WebDAV.
Table 6-1. The HTTP 1.1 response codes
Code and message
Meaning
HttpURLConnection constant
1XX
Informational.
100 Continue
The server is prepared to accept the request body and the client should
send it; allows clients to ask whether the server will accept a request
before they send a large amount of data as part of the request.
N/A
101 Switching
Protocols
The server accepts the client's request in the Upgrade header field to
change the application protocol (e.g., from HTTP to WebSockets.)
N/A
2XX Successful
Request succeeded.
200 OK
The most common response code. If the request method was GET or
POST , the requested data is contained in the response along with
the usual headers. If the request method was HEAD, only the header
information is included.
HTTP_OK
201 Created
The server has created a resource at the URL specified in the body of
the response. The client should now attempt to load that URL. This
code is only sent in response to POST requests.
HTTP_CREATED
202 Accepted
This rather uncommon response indicates that a request (generally
from POST ) is being processed, but the processing is not yet complete,
so no response can be returned. However, the server should return
an HTML page that explains the situation to the user and provide an
estimate of when the request is likely to be completed, and, ideally,
a link to a status monitor of some kind.
HTTP_ACCEPTED
203 Non-authoritative
Information
The resource representation was returned from a caching proxy or
other local source and is not guaranteed to be up to date.
HTTP_NOT_AUTHORITA
TIVE
Search WWH ::




Custom Search