public class BasicHttpClient extends Object implements HttpClient
Constructor and Description |
---|
BasicHttpClient(OutputStream os,
InputStream is)
Constructs a BasicHttpClient that communicates over
input and output streams.
|
BasicHttpClient(Socket socket)
Constructs a BasicHttpClient that communicates over
a socket.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying input and output streams.
|
OutputStream |
getOutputStream()
Returns a stream for writing data to, if data is to be sent to the
server.
|
ClientResponse |
readResponse()
Reads the response data from the HTTP server.
|
String |
toString()
Returns debug information.
|
void |
writeRequest(ClientRequest request)
Sends the first part of a
Request message,
consisting of a request line and headers. |
public BasicHttpClient(Socket socket) throws IOException
IOException
public BasicHttpClient(OutputStream os, InputStream is)
public void writeRequest(ClientRequest request) throws IOException
HttpClient
Request
message,
consisting of a request line and headers.
The message body may be sent in one of two ways:
DataPoster
in the client request
object.
HttpClient.getOutputStream()
.
writeRequest
in interface HttpClient
IOException
public OutputStream getOutputStream()
HttpClient
GET
, calling this
method of course makes little sense. Data must be sent if
content-length or transfer encoding headers were sent.
This stream should be wrapped to control output based on the
headers specified in the request.getOutputStream
in interface HttpClient
public ClientResponse readResponse() throws IOException
HttpClient
readResponse
in interface HttpClient
HttpException
- if the server returned an invalid HTTP
responseIOException
public void close() throws IOException
close
in interface HttpClient
IOException
Copyright © 2012. All Rights Reserved.