Cryptography Reference
In-Depth Information
return -1;
}
sprintf( get_command, “Connection: close\r\n\r\n” );
if ( send( connection, get_command, strlen( get_command ), 0 ) == -1 )
{
return -1;
}
return 0;
}
Finally, output the response from the server. To keep things simple, just dump
the contents of the response on stdout. An HTTP response has a standard for-
mat, just like an HTTP request. The response is the token HTTP/1.0 or HTTP/1.1
depending on which version the server understands (which does not necessarily
have to match the client's version), followed by a space, followed by a numeric
code indicating the status of the request — errored, rejected, processed, and so
on — followed by a space, followed by a textual, human-readable, description
of the meaning of the status code.
Some of the more common status codes are shown in Table 1-1.
Table 1-1: Common status codes
STATUS
MEANING
200
Everything was OK, requested document follows.
302
Requested document exists, but has been moved — new location
follows.
403
Forbidden: Requested document exists, but you are not authorized to
view it.
404
Requested document not found.
500
Internal Server Error.
There are quite a few more status codes, as described in RFC 2616. The response
status line is followed, again, by a CRLF, and a series of colon-separated, CRLF-
delimited headers, a standalone CRLF/blank line end-of-headers marker, and
the document itself. Here's an example HTTP response:
HTTP/1.1 200 OK
Date: Tue, 13 Oct 2009 19:34:51 GMT
Server: Apache
Last-Modified: Fri, 27 Oct 2006 01:53:57 GMT
ETag: “1876a-ff-316f5740”
Accept-Ranges: bytes
Search WWH ::




Custom Search