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

x33g5p2x  于2022-01-15 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(106)

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

AmazonHttpClient.handleResponse介绍

[英]Handles a successful response from a service call by unmarshalling the results using the specified response handler.
[中]通过使用指定的响应处理程序解组结果,处理来自服务调用的成功响应。

代码示例

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

final T response = handleResponse(request, responseHandler,
    httpResponse,
    executionContext);

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

@Test(expected = CRC32MismatchException.class)
public void testHandleResponseThrowsCRC32MisMatch() throws IOException {
  Request<?> request = new DefaultRequest<String>("ServiceName");
  final HttpResponse httpResponse = new HttpResponse.Builder().statusText("TestResponse")
      .statusCode(200).build();
  HttpResponseHandler<AmazonWebServiceResponse<String>> responseHandler = new HttpResponseHandler<AmazonWebServiceResponse<String>>() {
    @Override
    public AmazonWebServiceResponse<String> handle(HttpResponse response) throws Exception {
      assertSame(response, httpResponse);
      throw new CRC32MismatchException("test");
    }
    @Override
    public boolean needsConnectionLeftOpen() {
      return false;
    }
  };
  client.handleResponse(request, responseHandler, httpResponse,
      new ExecutionContext());
}

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

@Test(expected = IOException.class)
public void testHandleResponseThrowsIOException() throws IOException {
  Request<?> request = new DefaultRequest<String>("ServiceName");
  final HttpResponse httpResponse = new HttpResponse.Builder().statusText("TestResponse")
      .statusCode(200).build();
  HttpResponseHandler<AmazonWebServiceResponse<String>> responseHandler = new HttpResponseHandler<AmazonWebServiceResponse<String>>() {
    @Override
    public AmazonWebServiceResponse<String> handle(HttpResponse response) throws Exception {
      assertSame(response, httpResponse);
      throw new IOException("test");
    }
    @Override
    public boolean needsConnectionLeftOpen() {
      return false;
    }
  };
  client.handleResponse(request, responseHandler, httpResponse,
      new ExecutionContext());
}

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

@Test(expected = RuntimeException.class)
public void testHandleResponseWithNullResult() throws IOException {
  Request<?> request = new DefaultRequest<String>("ServiceName");
  final HttpResponse httpResponse = new HttpResponse.Builder().statusText("TestResponse")
      .statusCode(200).build();
  HttpResponseHandler<AmazonWebServiceResponse<String>> responseHandler = new HttpResponseHandler<AmazonWebServiceResponse<String>>() {
    @Override
    public AmazonWebServiceResponse<String> handle(HttpResponse response) throws Exception {
      assertSame(response, httpResponse);
      return null;
    }
    @Override
    public boolean needsConnectionLeftOpen() {
      return false;
    }
  };
  client.handleResponse(request, responseHandler, httpResponse,
      new ExecutionContext());
}

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

@Test(expected = Exception.class)
public void testHandleResponseThrowsGenericException() throws IOException {
  Request<?> request = new DefaultRequest<String>("ServiceName");
  final HttpResponse httpResponse = new HttpResponse.Builder().statusText("TestResponse")
      .statusCode(200).build();
  HttpResponseHandler<AmazonWebServiceResponse<String>> responseHandler = new HttpResponseHandler<AmazonWebServiceResponse<String>>() {
    @Override
    public AmazonWebServiceResponse<String> handle(HttpResponse response) throws Exception {
      assertSame(response, httpResponse);
      throw new Exception("test");
    }
    @Override
    public boolean needsConnectionLeftOpen() {
      return false;
    }
  };
  client.handleResponse(request, responseHandler, httpResponse,
      new ExecutionContext());
}

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

@Test
public void testHandleResponse() throws IOException {
  Request<?> request = new DefaultRequest<String>("ServiceName");
  final HttpResponse httpResponse = new HttpResponse.Builder().statusText("TestResponse")
      .statusCode(200).build();
  HttpResponseHandler<AmazonWebServiceResponse<String>> responseHandler = new HttpResponseHandler<AmazonWebServiceResponse<String>>() {
    @Override
    public AmazonWebServiceResponse<String> handle(HttpResponse response) throws Exception {
      assertSame(response, httpResponse);
      AmazonWebServiceResponse<String> awsResponse = new AmazonWebServiceResponse<String>();
      awsResponse.setResult("Result");
      return awsResponse;
    }
    @Override
    public boolean needsConnectionLeftOpen() {
      return false;
    }
  };
  assertEquals("Result", client.handleResponse(request, responseHandler, httpResponse,
      new ExecutionContext()));
}

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

final T response = handleResponse(request, responseHandler,
    httpResponse,
    executionContext);

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

final T response = handleResponse(request, responseHandler,
    httpResponse,
    executionContext);

相关文章