本文整理了Java中com.amazonaws.http.AmazonHttpClient
类的一些代码示例,展示了AmazonHttpClient
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AmazonHttpClient
类的具体详情如下:
包路径:com.amazonaws.http.AmazonHttpClient
类名称:AmazonHttpClient
[英]The Amazon HTTP Client class.
[中]AmazonHTTP客户端类。
代码示例来源:origin: aws/aws-sdk-java
/**
* Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the
* ExecutionContext beforehand.
**/
private <X, Y extends AmazonWebServiceRequest> Response<X> doInvoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
ExecutionContext executionContext, URI discoveredEndpoint, URI uriFromEndpointTrait) {
if (discoveredEndpoint != null) {
request.setEndpoint(discoveredEndpoint);
request.getOriginalRequest().getRequestClientOptions().appendUserAgent("endpoint-discovery");
} else if (uriFromEndpointTrait != null) {
request.setEndpoint(uriFromEndpointTrait);
} else {
request.setEndpoint(endpoint);
}
request.setTimeOffset(timeOffset);
HttpResponseHandler<AmazonServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(new JsonErrorResponseMetadata());
return client.execute(request, responseHandler, errorResponseHandler, executionContext);
}
代码示例来源:origin: aws/aws-sdk-java
@Override
public S3ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) {
return (S3ResponseMetadata)client.getResponseMetadataForRequest(request);
}
代码示例来源:origin: aws/aws-sdk-java
public AmazonHttpClient build() {
return new AmazonHttpClient(clientConfig,
retryPolicy,
requestMetricCollector,
useBrowserCompatibleHostNameVerifier,
calculateCRC32FromCompressedData);
}
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the
* ExecutionContext beforehand.
**/
private <X, Y extends AmazonWebServiceRequest> Response<X> doInvoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
ExecutionContext executionContext, URI discoveredEndpoint, URI uriFromEndpointTrait) {
if (discoveredEndpoint != null) {
request.setEndpoint(discoveredEndpoint);
request.getOriginalRequest().getRequestClientOptions().appendUserAgent("endpoint-discovery");
} else if (uriFromEndpointTrait != null) {
request.setEndpoint(uriFromEndpointTrait);
} else {
request.setEndpoint(endpoint);
}
request.setTimeOffset(timeOffset);
DefaultErrorResponseHandler errorResponseHandler = new DefaultErrorResponseHandler(exceptionUnmarshallers);
return client.execute(request, responseHandler, errorResponseHandler, executionContext);
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testSetUserAgentDefault() {
ClientConfiguration config = new ClientConfiguration();
client = new AmazonHttpClient(config);
final Request<?> request = new DefaultRequest<String>("ServiceName");
client.setUserAgent(request);
String userAgent = request.getHeaders().get("User-Agent");
assertEquals("same user agent", ClientConfiguration.DEFAULT_USER_AGENT, userAgent);
}
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* @deprecated by client configuration via the constructor. This method will
* be removed later on.
* @param clientConfiguration the client configuration.
*/
@Deprecated
@SuppressWarnings("checkstyle:hiddenfield")
public void setConfiguration(final ClientConfiguration clientConfiguration) {
final AmazonHttpClient existingClient = this.client;
RequestMetricCollector requestMetricCollector = null;
if (existingClient != null) {
requestMetricCollector = existingClient.getRequestMetricCollector();
existingClient.shutdown();
}
this.clientConfiguration = clientConfiguration;
this.client = new AmazonHttpClient(clientConfiguration, requestMetricCollector);
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the
* ExecutionContext beforehand.
**/
private <X, Y extends AmazonWebServiceRequest> Response<X> doInvoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
ExecutionContext executionContext, URI discoveredEndpoint, URI uriFromEndpointTrait) {
if (discoveredEndpoint != null) {
request.setEndpoint(discoveredEndpoint);
request.getOriginalRequest().getRequestClientOptions().appendUserAgent("endpoint-discovery");
} else if (uriFromEndpointTrait != null) {
request.setEndpoint(uriFromEndpointTrait);
} else {
request.setEndpoint(endpoint);
}
request.setTimeOffset(timeOffset);
DefaultErrorResponseHandler errorResponseHandler = new DefaultErrorResponseHandler(exceptionUnmarshallers);
return client.execute(request, responseHandler, errorResponseHandler, executionContext);
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testSetUserAgentCustom() {
String versionInfoUserAgent = ClientConfiguration.DEFAULT_USER_AGENT;
String customUserAgent = "custom_user_agent";
String requestUserAgent = "request_user_agent";
String targetUserAgent = versionInfoUserAgent + " " + requestUserAgent + " "
+ customUserAgent;
AmazonWebServiceRequest originalRequest = new AmazonWebServiceRequest() {
};
RequestClientOptions opts = originalRequest.getRequestClientOptions();
opts.appendUserAgent("request_user_agent");
ClientConfiguration config = new ClientConfiguration();
config.setUserAgent("custom_user_agent");
client = new AmazonHttpClient(config);
final Request<?> request = new DefaultRequest<String>(originalRequest, "ServiceName");
client.setUserAgent(request);
String userAgent = request.getHeaders().get("User-Agent");
assertEquals("same user agent", targetUserAgent, userAgent);
}
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the
* ExecutionContext beforehand.
**/
private <X, Y extends AmazonWebServiceRequest> Response<X> doInvoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
ExecutionContext executionContext, URI discoveredEndpoint, URI uriFromEndpointTrait) {
if (discoveredEndpoint != null) {
request.setEndpoint(discoveredEndpoint);
request.getOriginalRequest().getRequestClientOptions().appendUserAgent("endpoint-discovery");
} else if (uriFromEndpointTrait != null) {
request.setEndpoint(uriFromEndpointTrait);
} else {
request.setEndpoint(endpoint);
}
request.setTimeOffset(timeOffset);
HttpResponseHandler<AmazonServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(new JsonErrorResponseMetadata());
return client.execute(request, responseHandler, errorResponseHandler, executionContext);
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the
* ExecutionContext beforehand.
**/
private <X, Y extends AmazonWebServiceRequest> Response<X> doInvoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
ExecutionContext executionContext, URI discoveredEndpoint, URI uriFromEndpointTrait) {
if (discoveredEndpoint != null) {
request.setEndpoint(discoveredEndpoint);
request.getOriginalRequest().getRequestClientOptions().appendUserAgent("endpoint-discovery");
} else if (uriFromEndpointTrait != null) {
request.setEndpoint(uriFromEndpointTrait);
} else {
request.setEndpoint(endpoint);
}
request.setTimeOffset(timeOffset);
DefaultErrorResponseHandler errorResponseHandler = new DefaultErrorResponseHandler(exceptionUnmarshallers);
return client.execute(request, responseHandler, errorResponseHandler, executionContext);
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Returns additional metadata for a previously executed successful, request, typically used for debugging issues
* where a service isn't acting as expected. This data isn't considered part of the result data returned by an
* operation, so it's available through this separate, diagnostic interface.
* <p>
* Response metadata is only cached for a limited period of time, so if you need to access this extra diagnostic
* information for an executed request, you should use this method to retrieve it as soon as possible after
* executing the request.
*
* @param request
* The originally executed request
*
* @return The response metadata for the specified request, or null if none is available.
*/
public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) {
return client.getResponseMetadataForRequest(request);
}
代码示例来源:origin: aws/aws-sdk-java
@SdkProtectedApi
protected AmazonWebServiceClient(ClientConfiguration clientConfiguration,
RequestMetricCollector requestMetricCollector,
boolean disableStrictHostNameVerification) {
this.clientConfiguration = clientConfiguration;
requestHandler2s = new CopyOnWriteArrayList<RequestHandler2>();
monitoringListeners = new CopyOnWriteArrayList<MonitoringListener>();
client = new AmazonHttpClient(clientConfiguration,
requestMetricCollector, disableStrictHostNameVerification,
calculateCRC32FromCompressedData());
this.csmConfiguration = null;
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the
* ExecutionContext beforehand.
**/
private <X, Y extends AmazonWebServiceRequest> Response<X> doInvoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
ExecutionContext executionContext, URI discoveredEndpoint, URI uriFromEndpointTrait) {
if (discoveredEndpoint != null) {
request.setEndpoint(discoveredEndpoint);
request.getOriginalRequest().getRequestClientOptions().appendUserAgent("endpoint-discovery");
} else if (uriFromEndpointTrait != null) {
request.setEndpoint(uriFromEndpointTrait);
} else {
request.setEndpoint(endpoint);
}
request.setTimeOffset(timeOffset);
HttpResponseHandler<AmazonServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(new JsonErrorResponseMetadata());
return client.execute(request, responseHandler, errorResponseHandler, executionContext);
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the
* ExecutionContext beforehand.
**/
private <X, Y extends AmazonWebServiceRequest> Response<X> doInvoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
ExecutionContext executionContext, URI discoveredEndpoint, URI uriFromEndpointTrait) {
if (discoveredEndpoint != null) {
request.setEndpoint(discoveredEndpoint);
request.getOriginalRequest().getRequestClientOptions().appendUserAgent("endpoint-discovery");
} else if (uriFromEndpointTrait != null) {
request.setEndpoint(uriFromEndpointTrait);
} else {
request.setEndpoint(endpoint);
}
request.setTimeOffset(timeOffset);
DefaultErrorResponseHandler errorResponseHandler = new DefaultErrorResponseHandler(exceptionUnmarshallers);
return client.execute(request, responseHandler, errorResponseHandler, executionContext);
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Returns additional metadata for a previously executed successful, request, typically used for debugging issues
* where a service isn't acting as expected. This data isn't considered part of the result data returned by an
* operation, so it's available through this separate, diagnostic interface.
* <p>
* Response metadata is only cached for a limited period of time, so if you need to access this extra diagnostic
* information for an executed request, you should use this method to retrieve it as soon as possible after
* executing the request.
*
* @param request
* The originally executed request
*
* @return The response metadata for the specified request, or null if none is available.
*/
public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) {
return client.getResponseMetadataForRequest(request);
}
代码示例来源:origin: aws/aws-sdk-java
protected AmazonWebServiceClient(AwsSyncClientParams clientParams) {
this.clientConfiguration = clientParams.getClientConfiguration();
requestHandler2s = clientParams.getRequestHandlers();
monitoringListeners = new CopyOnWriteArrayList<MonitoringListener>();
client = new AmazonHttpClient(clientConfiguration, clientParams.getRequestMetricCollector(),
!useStrictHostNameVerification(),
calculateCRC32FromCompressedData());
this.csmConfiguration = getCsmConfiguration(clientParams.getClientSideMonitoringConfigurationProvider());
if (isCsmEnabled()) {
agentMonitoringListener = new AgentMonitoringListener(csmConfiguration.getPort());
monitoringListeners.add(agentMonitoringListener);
}
if (clientParams.getMonitoringListener() != null) {
monitoringListeners.add(clientParams.getMonitoringListener());
}
if (shouldGenerateClientSideMonitoringEvents()) {
requestHandler2s.add(new ClientSideMonitoringRequestHandler(getClientId(), monitoringListeners));
}
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the
* ExecutionContext beforehand.
**/
private <X, Y extends AmazonWebServiceRequest> Response<X> doInvoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
ExecutionContext executionContext, URI discoveredEndpoint, URI uriFromEndpointTrait) {
if (discoveredEndpoint != null) {
request.setEndpoint(discoveredEndpoint);
request.getOriginalRequest().getRequestClientOptions().appendUserAgent("endpoint-discovery");
} else if (uriFromEndpointTrait != null) {
request.setEndpoint(uriFromEndpointTrait);
} else {
request.setEndpoint(endpoint);
}
request.setTimeOffset(timeOffset);
HttpResponseHandler<AmazonServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(new JsonErrorResponseMetadata());
return client.execute(request, responseHandler, errorResponseHandler, executionContext);
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the
* ExecutionContext beforehand.
**/
private <X, Y extends AmazonWebServiceRequest> Response<X> doInvoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
ExecutionContext executionContext, URI discoveredEndpoint, URI uriFromEndpointTrait) {
if (discoveredEndpoint != null) {
request.setEndpoint(discoveredEndpoint);
request.getOriginalRequest().getRequestClientOptions().appendUserAgent("endpoint-discovery");
} else if (uriFromEndpointTrait != null) {
request.setEndpoint(uriFromEndpointTrait);
} else {
request.setEndpoint(endpoint);
}
request.setTimeOffset(timeOffset);
DefaultErrorResponseHandler errorResponseHandler = new DefaultErrorResponseHandler(exceptionUnmarshallers);
return client.execute(request, responseHandler, errorResponseHandler, executionContext);
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Returns additional metadata for a previously executed successful, request, typically used for debugging issues
* where a service isn't acting as expected. This data isn't considered part of the result data returned by an
* operation, so it's available through this separate, diagnostic interface.
* <p>
* Response metadata is only cached for a limited period of time, so if you need to access this extra diagnostic
* information for an executed request, you should use this method to retrieve it as soon as possible after
* executing the request.
*
* @param request
* The originally executed request
*
* @return The response metadata for the specified request, or null if none is available.
*/
public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) {
return client.getResponseMetadataForRequest(request);
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
public AmazonHttpClient build() {
return new AmazonHttpClient(clientConfig,
retryPolicy,
requestMetricCollector,
useBrowserCompatibleHostNameVerifier,
calculateCRC32FromCompressedData);
}
}
内容来源于网络,如有侵权,请联系作者删除!