public class GeneralDataPoster extends Object implements DataPoster
HttpClient client = new RetryHttpClient("http://example.net"); InputStream fileIS = new FileInputStream("somefile.jpeg"); DataPoster dataPoster = new GeneralDataPoster(fileIS, -1); RequestLine rl = new RequestLineImpl( ... ); ClientRequest request = new ClientRequestImpl(rl, dataPoster); client.writeRequest(request); ClientResponse response = client.readResponse();
Modifier and Type | Field and Description |
---|---|
protected int |
DEFAULT_BUFFER_SIZE
Default copy buffer size to create upon
initialization.
|
Constructor and Description |
---|
GeneralDataPoster()
Constructs a new, uninitialized
GeneralDataPoster . |
GeneralDataPoster(InputStream is,
int len)
Constructs a new
GeneralDataPoster that outputs data
from the specified stream. |
Modifier and Type | Method and Description |
---|---|
void |
init(InputStream is,
int len)
Sets the input stream to use and the number of bytes to send.
|
void |
sendData(OutputStream os)
Copies our input stream data to the supplied output stream.
|
String |
toString()
Returns a debug string.
|
protected int DEFAULT_BUFFER_SIZE
public GeneralDataPoster()
GeneralDataPoster
.
The init
method must be called before
this object can be used.public GeneralDataPoster(InputStream is, int len)
GeneralDataPoster
that outputs data
from the specified stream. Calls init
.public void init(InputStream is, int len)
is
- input stream to read for outputlen
- if zero, we do nothing, if < 0, we send
chunked data, if > 0 we sent only len
number of
bytespublic void sendData(OutputStream os) throws IOException
sendData
in interface DataPoster
os
- output stream to send data toIllegalHttpStateException
- if the input stream was never
setHttpException
- if the data was already read from our
stream, and the input stream cannot be reset
IOException
- if data could not be writtenCopyright © 2012. All Rights Reserved.