// -> is this a request for a specific version of the object? look for "versionId=" in the query string
String queryString = request.getQueryString();
if (null != queryString) engineRequest.setVersion( returnParameter( queryString, "versionId=" ));
S3GetObjectResponse engineResponse = ServiceProvider.getInstance().getS3Engine().handleRequest( engineRequest );
response.setStatus( engineResponse.getResultCode());
if (engineResponse.getResultCode() >=400 ) {
return;
}
String deleteMarker = engineResponse.getDeleteMarker();
if ( null != deleteMarker ) {
response.addHeader( "x-amz-delete-marker", "true" );
response.addHeader( "x-amz-version-id", deleteMarker );
}
else {
String version = engineResponse.getVersion();
if (null != version) response.addHeader( "x-amz-version-id", version );
}
// -> was the get conditional?
if (!conditionPassed( request, response, engineResponse.getLastModified().getTime(), engineResponse.getETag()))
return;
// -> is there data to return
// -> from the Amazon REST documentation it appears that Meta data is only returned as part of a HEAD request
//returnMetaData( engineResponse, response );
DataHandler dataHandler = engineResponse.getData();
if (dataHandler != null) {
response.addHeader("ETag", "\"" + engineResponse.getETag() + "\"");
response.addHeader("Last-Modified", DateHelper.getDateDisplayString(
DateHelper.GMT_TIMEZONE, engineResponse.getLastModified().getTime(), "E, d MMM yyyy HH:mm:ss z"));
response.setContentLength((int)engineResponse.getContentLength());
S3RestServlet.writeResponse(response, dataHandler.getInputStream());
}
}