Hi,
I have a requirement to upload a file, and to have the transfer of data
be interrupted in the event of the server responding with an error. My
code looks like:
MimetypesFileTypeMap mime = new MimetypesFileTypeMap();
request = new PostMethod(url);
MonitoredRequestEntity ent = new MonitoredRequestEntity(
stream, file.length(), mime.getContentType(file),
listener);
request.setRequestEntity(ent);
int status = 0;
try {
status = httpClient.executeMethod(request);
} catch (Exception e) {
if (!request.isAborted()) {
logger.error("http post failed for job {}", jobId, e);
listener.setStatus(new UploadStatus().setFailed());
}
return;
}
if (status != HttpStatus.SC_ACCEPTED && status !=
HttpStatus.SC_OK) {
throw new
MuseException(request.getStatusLine().toString());
}
It seems that the call to executeMethod is blocking until the entire
body of the RequestEntity has been written to the server before
processing the response. Is there a way to have the response processed
earlier? The files in question are very large and I would like to avoid
the transfer if possible.
I am using MultiThreadedHttpConnectionManager to manage connections if
that affects things.
f
http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal
views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on
it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]