Java Reference
In-Depth Information
Listing 12-5. Obtaining a Web Page
GET /index.html HTTP/1.1
Host: www.noplace.com
The first line of the request is the request itself; the request consists of a method, a
resource, and the version of the protocol. The GET request asks the remote server to return
the indicated resource—in this case, the document index.html —using HTTP version 1.1.
Subsequent lines of the request consist of metadata about the request, indicated as
name-value pairs demarcated by colons and separated by newlines, such as the server
destination host (in the example, www.noplace.com ). If a request includes an object body,
it follows the headers after a blank line, as shown in Listing 12-6.
Listing 12-6. Posting Information to a Web Server
POST /do HTTP/1.1
Host: www.noplace.com
name=value
Here, the remote server is being asked to process the object body name=value by
invoking the script do and passing the object body to the script. Table 12-4 shows a list of
the defined HTTP methods (also called verbs ) and their use.
Table 12-4. HTTP Methods and Their Meaning
Method
Meaning
HEAD
Asks for the response identical to the response created by a GET , but without the
object body
GET
Requests a representation of the specified resource
POST
Submits data to be processed by the specified resource
PUT
Uploads a representation of the specified resource
DELETE
Deletes the specified resource
TRACE
Echoes back the received request
OPTIONS
Returns the raw HTTP methods that the server supports for the resource
CONNECT
Converts the request connection to a transparent TCP tunnel
Returning to Listing 12-5, the server might make a response like the one shown in
Listing 12-7.
 
Search WWH ::




Custom Search