本文整理了Java中com.amazonaws.http.HttpResponse.getHeader()
方法的一些代码示例,展示了HttpResponse.getHeader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.getHeader()
方法的具体详情如下:
包路径:com.amazonaws.http.HttpResponse
类名称:HttpResponse
方法名:getHeader
[英]Looks up a header by name and returns its value. Does case insensitive comparison.
[中]按名称查找标题并返回其值。不区分大小写进行比较。
代码示例来源:origin: aws/aws-sdk-java
private long getContentLength(HttpResponse response) {
final String contentLength = response.getHeader("Content-Length");
if (contentLength == null) {
return -1;
} else {
return Long.parseLong(response.getHeader("Content-Length"));
}
}
代码示例来源:origin: aws/aws-sdk-java
exceptionBuilder.setStatusCode(httpResponse.getStatusCode());
exceptionBuilder.setCloudFrontId(httpResponse.getHeaders().get(Headers.CLOUD_FRONT_ID));
String bucketRegion = httpResponse.getHeader(Headers.S3_BUCKET_REGION);
if (bucketRegion != null) {
exceptionBuilder.addAdditionalDetail(Headers.S3_BUCKET_REGION, bucketRegion);
代码示例来源:origin: Nextdoor/bender
exceptionBuilder.setStatusCode(httpResponse.getStatusCode());
exceptionBuilder.setCloudFrontId(httpResponse.getHeaders().get(Headers.CLOUD_FRONT_ID));
String bucketRegion = httpResponse.getHeader(Headers.S3_BUCKET_REGION);
if (bucketRegion != null) {
exceptionBuilder.addAdditionalDetail(Headers.S3_BUCKET_REGION, bucketRegion);
代码示例来源:origin: aws/aws-sdk-java
/**
* Parse the error message from the response.
*
* @return Error Code of exceptional response or null if it can't be determined
*/
public String parseErrorMessage(HttpResponse httpResponse, JsonNode jsonNode) {
// If X_AMZN_ERROR_MESSAGE is present, prefer that. Otherwise check the JSON body.
final String headerMessage = httpResponse.getHeader(X_AMZN_ERROR_MESSAGE);
if (headerMessage != null) {
return headerMessage;
}
for (String field : errorMessageJsonLocations) {
JsonNode value = jsonNode.get(field);
if (value != null && value.isTextual()) {
return value.asText();
}
}
return null;
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
/**
* Parse the error message from the response.
*
* @return Error Code of exceptional response or null if it can't be determined
*/
public String parseErrorMessage(HttpResponse httpResponse, JsonNode jsonNode) {
// If X_AMZN_ERROR_MESSAGE is present, prefer that. Otherwise check the JSON body.
final String headerMessage = httpResponse.getHeader(X_AMZN_ERROR_MESSAGE);
if (headerMessage != null) {
return headerMessage;
}
for (String field : errorMessageJsonLocations) {
JsonNode value = jsonNode.get(field);
if (value != null && value.isTextual()) {
return value.asText();
}
}
return null;
}
代码示例来源:origin: Nextdoor/bender
private long getContentLength(HttpResponse response) {
final String contentLength = response.getHeader("Content-Length");
if (contentLength == null) {
return -1;
} else {
return Long.parseLong(response.getHeader("Content-Length"));
}
}
代码示例来源:origin: Nextdoor/bender
/**
* Parse the error message from the response.
*
* @return Error Code of exceptional response or null if it can't be determined
*/
public String parseErrorMessage(HttpResponse httpResponse, JsonNode jsonNode) {
// If X_AMZN_ERROR_MESSAGE is present, prefer that. Otherwise check the JSON body.
final String headerMessage = httpResponse.getHeader(X_AMZN_ERROR_MESSAGE);
if (headerMessage != null) {
return headerMessage;
}
for (String field : errorMessageJsonLocations) {
JsonNode value = jsonNode.get(field);
if (value != null && value.isTextual()) {
return value.asText();
}
}
return null;
}
代码示例来源:origin: aws/aws-xray-sdk-java
private void populateAndEndSubsegment(Subsegment currentSubsegment, Request<?> request, Response<?> response) {
if (null != response) {
String requestId = null;
if (response.getAwsResponse() instanceof AmazonWebServiceResult<?>) { // Not all services return responses extending AmazonWebServiceResult (e.g. S3)
ResponseMetadata metadata = ((AmazonWebServiceResult<?>) response.getAwsResponse()).getSdkResponseMetadata();
if (null != metadata) {
requestId = metadata.getRequestId();
if (null != requestId) {
currentSubsegment.putAws(REQUEST_ID_SUBSEGMENT_KEY, requestId);
}
}
} else if (null != response.getHttpResponse()) { // S3 does not follow request id header convention
if (null != response.getHttpResponse().getHeader(S3_REQUEST_ID_HEADER_KEY)) {
currentSubsegment.putAws(REQUEST_ID_SUBSEGMENT_KEY, response.getHttpResponse().getHeader(S3_REQUEST_ID_HEADER_KEY));
}
if (null != response.getHttpResponse().getHeader(EntityHeaderKeys.AWS.EXTENDED_REQUEST_ID_HEADER)) {
currentSubsegment.putAws(EntityDataKeys.AWS.EXTENDED_REQUEST_ID_KEY, response.getHttpResponse().getHeader(EntityHeaderKeys.AWS.EXTENDED_REQUEST_ID_HEADER));
}
}
currentSubsegment.putAllAws(extractResponseParameters(request, response.getAwsResponse()));
currentSubsegment.putAllHttp(extractHttpResponseInformation(response.getHttpResponse()));
}
finalizeSubsegment(request);
}
内容来源于网络,如有侵权,请联系作者删除!