本文整理了Java中org.jclouds.http.HttpResponse.getFirstHeaderOrNull()
方法的一些代码示例,展示了HttpResponse.getFirstHeaderOrNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.getFirstHeaderOrNull()
方法的具体详情如下:
包路径:org.jclouds.http.HttpResponse
类名称:HttpResponse
方法名:getFirstHeaderOrNull
暂无
代码示例来源:origin: jclouds/legacy-jclouds
@Override
public String apply(HttpResponse httpResponse) {
return httpResponse.getFirstHeaderOrNull(ACCOUNT_TEMPORARY_URL_KEY);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
public String apply(HttpResponse response) {
String location = response.getFirstHeaderOrNull(HttpHeaders.LOCATION);
String[] parts = location.split("/");
return parts[parts.length - 1];
}
}
代码示例来源:origin: org.apache.jclouds.api/openstack-nova
public String apply(HttpResponse response) {
String location = response.getFirstHeaderOrNull(HttpHeaders.LOCATION);
String[] parts = location.split("/");
return parts[parts.length - 1];
}
}
代码示例来源:origin: jclouds/legacy-jclouds
/**
* parses the http response headers to provide the CDN URI string.
*/
public URI apply(final HttpResponse from) {
String cdnUri = checkNotNull(from.getFirstHeaderOrNull(CloudFilesHeaders.CDN_URI),
CloudFilesHeaders.CDN_URI);
return URI.create(cdnUri);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
/**
* parses the http response headers to provide the CDN URI string.
*/
public URI apply(final HttpResponse from) {
String cdnUri = checkNotNull(from.getFirstHeaderOrNull(HPCloudObjectStorageHeaders.CDN_URI),
HPCloudObjectStorageHeaders.CDN_URI);
return URI.create(cdnUri);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
public Task apply(HttpResponse from) {
String location = from.getFirstHeaderOrNull(HttpHeaders.LOCATION);
if (location == null)
location = from.getFirstHeaderOrNull("location");
if (location != null) {
return new TaskImpl(URI.create(location), null, TaskStatus.QUEUED, new Date(), null, null, null, null);
} else {
throw new HttpResponseException("no uri in headers or content", null, from);
}
}
}
代码示例来源:origin: jclouds/legacy-jclouds
public String apply(HttpResponse from) {
releasePayload(from);
String eTag = from.getFirstHeaderOrNull(ETAG);
if (eTag == null) {
// TODO: Cloud Files sends incorrectly cased ETag header... Remove this when fixed.
eTag = from.getFirstHeaderOrNull("Etag");
}
if (eTag != null) {
return eTag;
}
throw new HttpException("did not receive ETag");
}
代码示例来源:origin: jclouds/legacy-jclouds
/**
* parses the http response headers to create a new {@link AccountMetadata} object.
*/
public AccountMetadata apply(final HttpResponse from) {
String bytesString = checkNotNull(from.getFirstHeaderOrNull(SwiftHeaders.ACCOUNT_BYTES_USED),
SwiftHeaders.ACCOUNT_BYTES_USED);
String containersCountString = checkNotNull(from.getFirstHeaderOrNull(SwiftHeaders.ACCOUNT_CONTAINER_COUNT),
SwiftHeaders.ACCOUNT_CONTAINER_COUNT);
return AccountMetadata.builder().containerCount(Long.parseLong(containersCountString))
.bytes(Long.parseLong(bytesString)).build();
}
}
代码示例来源:origin: org.apache.jclouds.api/swift
/**
* parses the http response headers to create a new {@link AccountMetadata} object.
*/
public AccountMetadata apply(final HttpResponse from) {
String bytesString = checkNotNull(from.getFirstHeaderOrNull(SwiftHeaders.ACCOUNT_BYTES_USED),
SwiftHeaders.ACCOUNT_BYTES_USED);
String containersCountString = checkNotNull(from.getFirstHeaderOrNull(SwiftHeaders.ACCOUNT_CONTAINER_COUNT),
SwiftHeaders.ACCOUNT_CONTAINER_COUNT);
return AccountMetadata.builder().containerCount(Long.parseLong(containersCountString))
.bytes(Long.parseLong(bytesString)).build();
}
}
代码示例来源:origin: jclouds/legacy-jclouds
@VisibleForTesting
protected void addETagTo(HttpResponse from, MutableContainerPropertiesWithMetadata metadata) {
String eTag = from.getFirstHeaderOrNull(HttpHeaders.ETAG);
if (metadata.getETag() == null && eTag != null) {
metadata.setETag(eTag);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
/**
* ETag == Content-MD5
*/
@VisibleForTesting
protected void addETagTo(HttpResponse from, MutableObjectMetadata metadata) {
if (metadata.getETag() == null) {
String eTagHeader = from.getFirstHeaderOrNull(userMdPrefix + "object-eTag");
if (eTagHeader != null) {
metadata.setETag(eTagHeader);
}
}
}
代码示例来源:origin: jclouds/legacy-jclouds
public PublicAccess apply(HttpResponse from) {
releasePayload(from);
String access = from.getFirstHeaderOrNull("x-ms-blob-public-access");
if (access == null) {
return PublicAccess.PRIVATE;
}
return PublicAccess.valueOf(access.toUpperCase());
}
代码示例来源:origin: jclouds/legacy-jclouds
protected void addETagTo(HttpResponse from, MutableBlobMetadata metadata) {
String eTag = from.getFirstHeaderOrNull(HttpHeaders.ETAG);
if (metadata.getETag() == null && eTag != null) {
metadata.setETag(eTag);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
public ContainerMetadata apply(HttpResponse from) {
return ContainerMetadata.builder().name(request.getInvocation().getArgs().get(0).toString())
.readACL(from.getFirstHeaderOrNull(SwiftHeaders.CONTAINER_READ))
.bytes(Long.valueOf(from.getFirstHeaderOrNull(SwiftHeaders.CONTAINER_BYTES_USED)))
.count(Long.valueOf(from.getFirstHeaderOrNull(SwiftHeaders.CONTAINER_OBJECT_COUNT)))
.metadata(extractUserMetadata(from)).build();
}
代码示例来源:origin: org.jclouds.api/swift
public ContainerMetadata apply(HttpResponse from) {
return ContainerMetadata.builder().name(request.getInvocation().getArgs().get(0).toString())
.readACL(from.getFirstHeaderOrNull(SwiftHeaders.CONTAINER_READ))
.bytes(Long.valueOf(from.getFirstHeaderOrNull(SwiftHeaders.CONTAINER_BYTES_USED)))
.count(Long.valueOf(from.getFirstHeaderOrNull(SwiftHeaders.CONTAINER_OBJECT_COUNT)))
.metadata(extractUserMetadata(from)).build();
}
代码示例来源:origin: jclouds/legacy-jclouds
/**
* parses the http response headers to create a new {@link BoundedSet} object.
*/
public BoundedSet<DirectoryEntry> apply(HttpResponse from) {
checkNotNull(from, "http response");
String token = from.getFirstHeaderOrNull(AtmosHeaders.TOKEN);
return new BoundedLinkedHashSet<DirectoryEntry>(factory.create(listHandlerProvider.get()).parse(
from.getPayload().getInput()), token);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
@Override
public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) {
String location = response.getFirstHeaderOrNull(LOCATION);
if (location != null && location.indexOf("Job") != -1) {
HttpRequest getRequest = command.getCurrentRequest().toBuilder()
.method(GET)
.payload((Payload) null).build();
command.setCurrentRequest(getRequest);
}
return super.shouldRetryRequest(command, response);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
@VisibleForTesting
void parseLastModifiedOrThrowException(HttpResponse from, MutableContainerPropertiesWithMetadata metadata)
throws HttpException {
String lastModified = from.getFirstHeaderOrNull(HttpHeaders.LAST_MODIFIED);
if (lastModified == null)
throw new HttpException(HttpHeaders.LAST_MODIFIED + " header not present in response: " + from);
metadata.setLastModified(dateParser.rfc822DateParse(lastModified));
if (metadata.getLastModified() == null)
throw new HttpException("could not parse: " + HttpHeaders.LAST_MODIFIED + ": " + lastModified);
}
代码示例来源:origin: io.cloudsoft.jclouds.labs/vcloud-director
@Override
public SessionWithToken apply(final HttpResponse from) {
Session session = sessionParser.apply(from);
return SessionWithToken.builder().session(session).token(from.getFirstHeaderOrNull("x-vcloud-authorization"))
.build();
}
}
代码示例来源:origin: jclouds/legacy-jclouds
public AzureStorageError parseAzureStorageErrorFromContent(HttpCommand command,
HttpResponse response, InputStream content) throws HttpException {
AzureStorageError error = factory.create(errorHandlerProvider.get()).parse(content);
error.setRequestId(response.getFirstHeaderOrNull(AzureStorageHeaders.REQUEST_ID));
if ("AuthenticationFailed".equals(error.getCode())) {
error.setStringSigned(signer.createStringToSign(command.getCurrentRequest()));
error.setSignature(signer.signString(error.getStringSigned()));
}
return error;
}
内容来源于网络,如有侵权,请联系作者删除!