com.amazonaws.http.HttpResponse.getHttpRequest()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中com.amazonaws.http.HttpResponse.getHttpRequest()方法的一些代码示例,展示了HttpResponse.getHttpRequest()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.getHttpRequest()方法的具体详情如下:
包路径:com.amazonaws.http.HttpResponse
类名称:HttpResponse
方法名:getHttpRequest

HttpResponse.getHttpRequest介绍

[英]Returns the original http request associated with this response.
[中]返回与此响应关联的原始http请求。

代码示例

代码示例来源:origin: apache/nifi

protected void logResponse(ComponentLog logger, GenericApiGatewayResponse response) {
  try {
    logger.debug("\nResponse from remote service:\n\t{}\n{}",
        new Object[]{response.getHttpResponse().getHttpRequest().getURI().toURL().toExternalForm(), getLogString(response.getHttpResponse().getHeaders())});
  } catch (MalformedURLException e) {
    logger.debug(e.getMessage());
  }
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Determine if an interrupted exception is caused by the client execution timer
 * interrupting the current thread or some other task interrupting the thread for another
 * purpose.
 *
 * @return {@link ClientExecutionTimeoutException} if the {@link InterruptedException} was
 * caused by the {@link ClientExecutionTimer}. Otherwise re-interrupts the current thread
 * and returns a {@link SdkClientException} wrapping an {@link InterruptedException}
 */
private RuntimeException handleInterruptedException(InterruptedException e) {
  if (e instanceof SdkInterruptedException) {
    if (((SdkInterruptedException) e).getResponse() != null) {
      ((SdkInterruptedException) e).getResponse().getHttpResponse().getHttpRequest().abort();
    }
  }
  if (executionContext.getClientExecutionTrackerTask().hasTimeoutExpired()) {
    // Clear the interrupt status
    Thread.interrupted();
    ClientExecutionTimeoutException exception = new ClientExecutionTimeoutException();
    reportClientExecutionTimeout(exception);
    return exception;
  } else {
    Thread.currentThread().interrupt();
    return new AbortedException(e);
  }
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * @see com.amazonaws.http.HttpResponseHandler#handle(com.amazonaws.http.HttpResponse)
 */
public AmazonWebServiceResponse<S3Object> handle(HttpResponse response) throws Exception {
  /*
   * TODO: It'd be nice to set the bucket name and key here, but the information isn't easy to
   * pull out of the response/request currently.
   */
  S3Object object = new S3Object();
  AmazonWebServiceResponse<S3Object> awsResponse = parseResponseMetadata(response);
  if (response.getHeaders().get(Headers.REDIRECT_LOCATION) != null) {
    object.setRedirectLocation(response.getHeaders().get(Headers.REDIRECT_LOCATION));
  }
  // If the requester is charged when downloading a object from an
  // Requester Pays bucket, then this header is set.
  if (response.getHeaders().get(Headers.REQUESTER_CHARGED_HEADER) != null) {
    object.setRequesterCharged(true);
  }
  if (response.getHeaders().get(Headers.S3_TAGGING_COUNT) != null) {
    object.setTaggingCount(Integer.parseInt(response.getHeaders().get(Headers.S3_TAGGING_COUNT)));
  }
  ObjectMetadata metadata = object.getObjectMetadata();
  populateObjectMetadata(response, metadata);
  object.setObjectContent(new S3ObjectInputStream(response.getContent(), response.getHttpRequest()));
  awsResponse.setResult(object);
  return awsResponse;
}

代码示例来源:origin: com.amazonaws/aws-java-sdk-core

/**
 * Determine if an interrupted exception is caused by the client execution timer
 * interrupting the current thread or some other task interrupting the thread for another
 * purpose.
 *
 * @return {@link ClientExecutionTimeoutException} if the {@link InterruptedException} was
 * caused by the {@link ClientExecutionTimer}. Otherwise re-interrupts the current thread
 * and returns a {@link SdkClientException} wrapping an {@link InterruptedException}
 */
private RuntimeException handleInterruptedException(InterruptedException e) {
  if (e instanceof SdkInterruptedException) {
    if (((SdkInterruptedException) e).getResponse() != null) {
      ((SdkInterruptedException) e).getResponse().getHttpResponse().getHttpRequest().abort();
    }
  }
  if (executionContext.getClientExecutionTrackerTask().hasTimeoutExpired()) {
    // Clear the interrupt status
    Thread.interrupted();
    ClientExecutionTimeoutException exception = new ClientExecutionTimeoutException();
    reportClientExecutionTimeout(exception);
    return exception;
  } else {
    Thread.currentThread().interrupt();
    return new AbortedException(e);
  }
}

代码示例来源:origin: Nextdoor/bender

private S3AbortableInputStream abortableIs(HttpResponse response) {
  return new S3AbortableInputStream(response.getContent(), response.getHttpRequest(), getContentLength(response));
}

代码示例来源:origin: org.apache.nifi/nifi-aws-abstract-processors

protected void logResponse(ComponentLog logger, GenericApiGatewayResponse response) {
  try {
    logger.debug("\nResponse from remote service:\n\t{}\n{}",
        new Object[]{response.getHttpResponse().getHttpRequest().getURI().toURL().toExternalForm(), getLogString(response.getHttpResponse().getHeaders())});
  } catch (MalformedURLException e) {
    logger.debug(e.getMessage());
  }
}

代码示例来源:origin: Nextdoor/bender

/**
 * Determine if an interrupted exception is caused by the client execution timer
 * interrupting the current thread or some other task interrupting the thread for another
 * purpose.
 *
 * @return {@link ClientExecutionTimeoutException} if the {@link InterruptedException} was
 * caused by the {@link ClientExecutionTimer}. Otherwise re-interrupts the current thread
 * and returns a {@link SdkClientException} wrapping an {@link InterruptedException}
 */
private RuntimeException handleInterruptedException(InterruptedException e) {
  if (e instanceof SdkInterruptedException) {
    if (((SdkInterruptedException) e).getResponse() != null) {
      ((SdkInterruptedException) e).getResponse().getHttpResponse().getHttpRequest().abort();
    }
  }
  if (executionContext.getClientExecutionTrackerTask().hasTimeoutExpired()) {
    // Clear the interrupt status
    Thread.interrupted();
    return new ClientExecutionTimeoutException();
  } else {
    Thread.currentThread().interrupt();
    return new AbortedException(e);
  }
}

代码示例来源:origin: Nextdoor/bender

/**
 * @see com.amazonaws.http.HttpResponseHandler#handle(com.amazonaws.http.HttpResponse)
 */
public AmazonWebServiceResponse<S3Object> handle(HttpResponse response) throws Exception {
  /*
   * TODO: It'd be nice to set the bucket name and key here, but the information isn't easy to
   * pull out of the response/request currently.
   */
  S3Object object = new S3Object();
  AmazonWebServiceResponse<S3Object> awsResponse = parseResponseMetadata(response);
  if (response.getHeaders().get(Headers.REDIRECT_LOCATION) != null) {
    object.setRedirectLocation(response.getHeaders().get(Headers.REDIRECT_LOCATION));
  }
  // If the requester is charged when downloading a object from an
  // Requester Pays bucket, then this header is set.
  if (response.getHeaders().get(Headers.REQUESTER_CHARGED_HEADER) != null) {
    object.setRequesterCharged(true);
  }
  if (response.getHeaders().get(Headers.S3_TAGGING_COUNT) != null) {
    object.setTaggingCount(Integer.parseInt(response.getHeaders().get(Headers.S3_TAGGING_COUNT)));
  }
  ObjectMetadata metadata = object.getObjectMetadata();
  populateObjectMetadata(response, metadata);
  object.setObjectContent(new S3ObjectInputStream(abortableIs(response), response.getHttpRequest()));
  awsResponse.setResult(object);
  return awsResponse;
}

相关文章