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
IOExceptionpublic BasicHttpClient(OutputStream os, InputStream is)
public void writeRequest(ClientRequest request) throws IOException
HttpClientRequest 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 HttpClientIOExceptionpublic OutputStream getOutputStream()
HttpClientGET, 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 HttpClientpublic ClientResponse readResponse() throws IOException
HttpClientreadResponse in interface HttpClientHttpException - if the server returned an invalid HTTP
responseIOExceptionpublic void close()
throws IOException
close in interface HttpClientIOExceptionCopyright © 2012. All Rights Reserved.