本文整理了Java中com.amazonaws.http.StaxResponseHandler.handle()
方法的一些代码示例,展示了StaxResponseHandler.handle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StaxResponseHandler.handle()
方法的具体详情如下:
包路径:com.amazonaws.http.StaxResponseHandler
类名称:StaxResponseHandler
方法名:handle
暂无
代码示例来源:origin: aws/aws-sdk-java
/**
* Confirms a subscription by visiting the provided URL.
*
* @param httpClient Client to use to visit URL.
* @param subscribeUrl Confirmation URL.
* @return Result of subscription confirmation.
*/
static ConfirmSubscriptionResult confirmSubscription(HttpClient httpClient, String subscribeUrl) {
try {
HttpGet request = new HttpGet(subscribeUrl);
HttpResponse response = httpClient.execute(request);
if (ApacheUtils.isRequestSuccessful(response)) {
return new StaxResponseHandler<ConfirmSubscriptionResult>(ConfirmSubscriptionResultStaxUnmarshaller.getInstance())
.handle(ApacheUtils.createResponse(null, request, response, null)).getResult();
} else {
throw new HttpException("Could not confirm subscription", response);
}
} catch (Exception e) {
throw new SdkClientException(e);
}
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testHandleWithContent() throws Exception {
final ByteArrayInputStream bais = new ByteArrayInputStream(
("<data>Content</data>").getBytes(StringUtils.UTF8));
final HttpResponse response = new HttpResponse.Builder().header("testKey", "testValue")
.header("x-amzn-RequestId", "99")
.content(bais).build();
Unmarshaller<String, StaxUnmarshallerContext> unmarshaller = new Unmarshaller<String, StaxUnmarshallerContext>() {
@Override
public String unmarshall(StaxUnmarshallerContext in) throws Exception {
in.nextEvent();
String content = in.readText();
assertEquals(content, "Content");
assertEquals(in.getHeader("testKey"), "testValue");
return content;
}
};
StaxResponseHandler<String> handler = new StaxResponseHandler<String>(unmarshaller);
AmazonWebServiceResponse<String> awsr = handler.handle(response);
assertEquals(awsr.getResponseMetadata().getRequestId(), "99");
assertEquals(awsr.getResult(), "Content");
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testHandleWithNullContent() throws Exception {
final HttpResponse response = new HttpResponse.Builder().header("testKey", "testValue")
.content(null).build();
Unmarshaller<String, StaxUnmarshallerContext> unmarshaller = new Unmarshaller<String, StaxUnmarshallerContext>() {
@Override
public String unmarshall(StaxUnmarshallerContext in) throws Exception {
assertEquals(in.getHeader("testKey"), "testValue");
return "Test";
}
};
StaxResponseHandler<String> handler = new StaxResponseHandler<String>(unmarshaller);
assertEquals(handler.handle(response).getResult(), "Test");
}
}
内容来源于网络,如有侵权,请联系作者删除!