use of com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils.HTTPRequestInfo in project appengine-gcs-client by GoogleCloudPlatform.
the class OauthRawGcsService method getObjectMetadata.
@Override
public GcsFileMetadata getObjectMetadata(GcsFilename filename, long timeoutMillis) throws IOException {
HTTPRequest req = makeRequest(filename, null, HEAD, timeoutMillis);
HTTPResponse resp;
try {
resp = urlfetch.fetch(req);
} catch (IOException e) {
throw createIOException(new HTTPRequestInfo(req), e);
}
int responseCode = resp.getResponseCode();
if (responseCode == 404) {
return null;
}
if (responseCode != 200) {
throw HttpErrorHandler.error(new HTTPRequestInfo(req), resp);
}
return getMetadataFromResponse(filename, resp, getLengthFromHeader(resp, X_GOOG_CONTENT_LENGTH));
}
use of com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils.HTTPRequestInfo in project appengine-gcs-client by GoogleCloudPlatform.
the class OauthRawGcsService method deleteObject.
/**
* True if deleted, false if not found.
*/
@Override
public boolean deleteObject(GcsFilename filename, long timeoutMillis) throws IOException {
HTTPRequest req = makeRequest(filename, null, DELETE, timeoutMillis);
HTTPResponse resp;
try {
resp = urlfetch.fetch(req);
} catch (IOException e) {
throw createIOException(new HTTPRequestInfo(req), e);
}
switch(resp.getResponseCode()) {
case 204:
return true;
case 404:
return false;
default:
throw HttpErrorHandler.error(new HTTPRequestInfo(req), resp);
}
}
Aggregations