本文整理了Java中com.amazonaws.http.HttpResponse.getRequest()
方法的一些代码示例,展示了HttpResponse.getRequest()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.getRequest()
方法的具体详情如下:
包路径:com.amazonaws.http.HttpResponse
类名称:HttpResponse
方法名:getRequest
[英]Returns the original request associated with this response.
[中]返回与此响应关联的原始请求。
代码示例来源:origin: aws/aws-sdk-java
private String idString(HttpResponse errorResponse) {
StringBuilder idString = new StringBuilder();
try {
if (errorResponse.getRequest().getHeaders().containsKey(HEADER_SDK_TRANSACTION_ID)) {
idString.append("Invocation Id:").append(errorResponse.getRequest().getHeaders().get(HEADER_SDK_TRANSACTION_ID));
}
if (errorResponse.getHeaders().containsKey(X_AMZN_REQUEST_ID_HEADER)) {
if (idString.length() > 0) {
idString.append(", ");
}
idString.append("Request Id:").append(errorResponse.getHeaders().get(X_AMZN_REQUEST_ID_HEADER));
}
} catch (NullPointerException npe){
log.debug("Error getting Request or Invocation ID from response", npe);
}
return idString.length() > 0 ? idString.toString() : "Unknown";
}
代码示例来源:origin: aws/aws-sdk-java
|| httpResponse.getRequest().getHttpMethod() == HttpMethodName.HEAD) {
return createExceptionFromHeaders(httpResponse, null);
代码示例来源:origin: aws/aws-sdk-java
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
final AmazonServiceException ase = handleAse(response);
ase.setStatusCode(response.getStatusCode());
ase.setServiceName(response.getRequest().getServiceName());
awsRequestMetrics.addPropertyWith(AWSRequestMetrics.Field.AWSRequestID, ase.getRequestId())
.addPropertyWith(AWSRequestMetrics.Field.AWSErrorCode, ase.getErrorCode())
.addPropertyWith(AWSRequestMetrics.Field.StatusCode, ase.getStatusCode());
return ase;
}
代码示例来源:origin: aws/aws-sdk-java
private AmazonServiceException handleAse(HttpResponse response) throws Exception {
final int statusCode = response.getStatusCode();
try {
return delegate.handle(response);
} catch(InterruptedException e) {
throw e;
} catch (Exception e) {
// If the errorResponseHandler doesn't work, then check for error responses that don't have any content
if (statusCode == 413) {
AmazonServiceException exception = new AmazonServiceException("Request entity too large");
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Client);
exception.setErrorCode("Request entity too large");
return exception;
} else if (statusCode >= 500 && statusCode < 600) {
AmazonServiceException exception = new AmazonServiceException(response.getStatusText());
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Service);
exception.setErrorCode(response.getStatusText());
return exception;
} else {
throw e;
}
}
}
代码示例来源:origin: aws/aws-sdk-java
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
JsonContent jsonContent = JsonContent.createJsonContent(response, jsonFactory);
String errorCode = errorCodeParser.parseErrorCode(response, jsonContent);
AmazonServiceException ase = createException(errorCode, jsonContent);
// Jackson has special-casing for 'message' values when deserializing
// Throwables, but sometimes the service passes the error message in
// other JSON fields - handle it here.
if (ase.getErrorMessage() == null) {
ase.setErrorMessage(errorMessageParser.parseErrorMessage(response, jsonContent.getJsonNode()));
}
ase.setErrorCode(errorCode);
ase.setServiceName(response.getRequest().getServiceName());
ase.setStatusCode(response.getStatusCode());
ase.setErrorType(getErrorTypeFromStatusCode(response.getStatusCode()));
ase.setRawResponse(jsonContent.getRawContent());
String requestId = getRequestIdFromHeaders(response.getHeaders());
if (requestId != null) {
ase.setRequestId(requestId);
}
ase.setHttpHeaders(response.getHeaders());
return ase;
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
private String idString(HttpResponse errorResponse) {
StringBuilder idString = new StringBuilder();
try {
if (errorResponse.getRequest().getHeaders().containsKey(HEADER_SDK_TRANSACTION_ID)) {
idString.append("Invocation Id:").append(errorResponse.getRequest().getHeaders().get(HEADER_SDK_TRANSACTION_ID));
}
if (errorResponse.getHeaders().containsKey(X_AMZN_REQUEST_ID_HEADER)) {
if (idString.length() > 0) {
idString.append(", ");
}
idString.append("Request Id:").append(errorResponse.getHeaders().get(X_AMZN_REQUEST_ID_HEADER));
}
} catch (NullPointerException npe){
log.debug("Error getting Request or Invocation ID from response", npe);
}
return idString.length() > 0 ? idString.toString() : "Unknown";
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
final AmazonServiceException ase = handleAse(response);
ase.setStatusCode(response.getStatusCode());
ase.setServiceName(response.getRequest().getServiceName());
awsRequestMetrics.addPropertyWith(AWSRequestMetrics.Field.AWSRequestID, ase.getRequestId())
.addPropertyWith(AWSRequestMetrics.Field.AWSErrorCode, ase.getErrorCode())
.addPropertyWith(AWSRequestMetrics.Field.StatusCode, ase.getStatusCode());
return ase;
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
private AmazonServiceException handleAse(HttpResponse response) throws Exception {
final int statusCode = response.getStatusCode();
try {
return delegate.handle(response);
} catch(InterruptedException e) {
throw e;
} catch (Exception e) {
// If the errorResponseHandler doesn't work, then check for error responses that don't have any content
if (statusCode == 413) {
AmazonServiceException exception = new AmazonServiceException("Request entity too large");
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Client);
exception.setErrorCode("Request entity too large");
return exception;
} else if (statusCode >= 500 && statusCode < 600) {
AmazonServiceException exception = new AmazonServiceException(response.getStatusText());
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Service);
exception.setErrorCode(response.getStatusText());
return exception;
} else {
throw e;
}
}
}
代码示例来源:origin: Nextdoor/bender
private String idString(HttpResponse errorResponse) {
StringBuilder idString = new StringBuilder();
try {
if (errorResponse.getRequest().getHeaders().containsKey(HEADER_SDK_TRANSACTION_ID)) {
idString.append("Invocation Id:").append(errorResponse.getRequest().getHeaders().get(HEADER_SDK_TRANSACTION_ID));
}
if (errorResponse.getHeaders().containsKey(X_AMZN_REQUEST_ID_HEADER)) {
if (idString.length() > 0) { idString.append(", "); }
idString.append("Request Id:").append(errorResponse.getHeaders().get(X_AMZN_REQUEST_ID_HEADER));
}
} catch (NullPointerException npe){
log.info("Error getting Request or Invocation ID from response", npe);
}
return idString.length() > 0 ? idString.toString() : "Unknown";
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
JsonContent jsonContent = JsonContent.createJsonContent(response, jsonFactory);
String errorCode = errorCodeParser.parseErrorCode(response, jsonContent);
AmazonServiceException ase = createException(errorCode, jsonContent);
// Jackson has special-casing for 'message' values when deserializing
// Throwables, but sometimes the service passes the error message in
// other JSON fields - handle it here.
if (ase.getErrorMessage() == null) {
ase.setErrorMessage(errorMessageParser.parseErrorMessage(response, jsonContent.getJsonNode()));
}
ase.setErrorCode(errorCode);
ase.setServiceName(response.getRequest().getServiceName());
ase.setStatusCode(response.getStatusCode());
ase.setErrorType(getErrorTypeFromStatusCode(response.getStatusCode()));
ase.setRawResponse(jsonContent.getRawContent());
String requestId = getRequestIdFromHeaders(response.getHeaders());
if (requestId != null) {
ase.setRequestId(requestId);
}
ase.setHttpHeaders(response.getHeaders());
return ase;
}
代码示例来源:origin: com.amazonaws/aws-hal-client-java
public AmazonServiceException handle(HttpResponse response)
throws Exception {
JSONObject jsonBody = getBodyAsJson(response);
Class<? extends AmazonServiceException> exceptionClass = exceptionClasses.get(response.getStatusCode());
AmazonServiceException result;
// Support other attribute names for the message?
// TODO: Inspect exception type (caching details) and apply other values from the body
String message = jsonBody.has("message") ? jsonBody.getString("message") : jsonBody.getString("Message");
if (exceptionClass != null) {
result = exceptionClass.getConstructor(String.class).newInstance(message);
} else {
result = AmazonServiceException.class.getConstructor(String.class).newInstance(message);
}
result.setServiceName(response.getRequest().getServiceName());
result.setStatusCode(response.getStatusCode());
if (response.getStatusCode() < 500) {
result.setErrorType(ErrorType.Client);
} else {
result.setErrorType(ErrorType.Service);
}
for (Entry<String, String> headerEntry : response.getHeaders().entrySet()) {
if (headerEntry.getKey().equalsIgnoreCase("X-Amzn-RequestId")) {
result.setRequestId(headerEntry.getValue());
}
}
return result;
}
代码示例来源:origin: Nextdoor/bender
|| httpResponse.getRequest().getHttpMethod() == HttpMethodName.HEAD) {
return createExceptionFromHeaders(httpResponse, null);
代码示例来源:origin: Nextdoor/bender
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
final AmazonServiceException ase = handleAse(response);
ase.setStatusCode(response.getStatusCode());
ase.setServiceName(response.getRequest().getServiceName());
awsRequestMetrics.addPropertyWith(AWSRequestMetrics.Field.AWSRequestID, ase.getRequestId())
.addPropertyWith(AWSRequestMetrics.Field.AWSErrorCode, ase.getErrorCode())
.addPropertyWith(AWSRequestMetrics.Field.StatusCode, ase.getStatusCode());
return ase;
}
代码示例来源:origin: Nextdoor/bender
private AmazonServiceException handleAse(HttpResponse response) throws Exception {
final int statusCode = response.getStatusCode();
try {
return delegate.handle(response);
} catch(InterruptedException e) {
throw e;
} catch (Exception e) {
// If the errorResponseHandler doesn't work, then check for error responses that don't have any content
if (statusCode == 413) {
AmazonServiceException exception = new AmazonServiceException("Request entity too large");
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Client);
exception.setErrorCode("Request entity too large");
return exception;
} else if (statusCode >= 500 && statusCode < 600) {
AmazonServiceException exception = new AmazonServiceException(response.getStatusText());
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Service);
exception.setErrorCode(response.getStatusText());
return exception;
} else {
throw e;
}
}
}
代码示例来源:origin: Nextdoor/bender
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
JsonContent jsonContent = JsonContent.createJsonContent(response, jsonFactory);
String errorCode = errorCodeParser.parseErrorCode(response, jsonContent);
AmazonServiceException ase = createException(errorCode, jsonContent);
// Jackson has special-casing for 'message' values when deserializing
// Throwables, but sometimes the service passes the error message in
// other JSON fields - handle it here.
if (ase.getErrorMessage() == null) {
ase.setErrorMessage(errorMessageParser.parseErrorMessage(response, jsonContent.getJsonNode()));
}
ase.setErrorCode(errorCode);
ase.setServiceName(response.getRequest().getServiceName());
ase.setStatusCode(response.getStatusCode());
ase.setErrorType(getErrorTypeFromStatusCode(response.getStatusCode()));
ase.setRawResponse(jsonContent.getRawContent());
String requestId = getRequestIdFromHeaders(response.getHeaders());
if (requestId != null) {
ase.setRequestId(requestId);
}
ase.setHttpHeaders(response.getHeaders());
return ase;
}
内容来源于网络,如有侵权,请联系作者删除!