// @Override
public void HttpConnectionStateChanged(NIOHttpConnection theConnection,State oldState, State state) {
if (oldState == State.PARSING_HEADERS && state == State.RECEIVING_CONTENT) {
NIOHttpHeaders headers = theConnection.getResponseHeaders();
LOG.info("*** S3 INCOMING HEADERS:" + headers.toString());
LOG.info("Content Length From Header for:" + theConnection.getURL() + " is:" + headers.findValue("Content-Length"));
}
LOG.info("S3Download Connection:" + theConnection.getURL() +" Old State:" + oldState + " NewState:" + state);
// get context
S3DownloadItem item = (S3DownloadItem) theConnection.getContext();
// if we started receiving content ...
if (state == State.RECEIVING_CONTENT) {
// this means we successfully parsed http header ...
// pick up etag and content length for the item ...
NIOHttpHeaders headers = theConnection.getResponseHeaders();
int resultCode = NIOHttpConnection.getHttpResponseCode(headers);
boolean continueDownloading = false;
boolean isContinuation = false;
if (item != null) {
// if success
if (resultCode >= 200 && resultCode <300) {
continueDownloading = true;
String etagValue = headers.findValue("ETag");
String contentLengthValue = headers.findValue("Content-Length");
String rangeValue = headers.findValue("Content-Range");
if(etagValue != null && contentLengthValue != null) {
try {
// now check range value .. in case it is set ...
if (rangeValue != null) {