com.amazonaws.http.UrlHttpClient类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(17.6k)|赞(0)|评价(0)|浏览(135)

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

UrlHttpClient介绍

[英]An implementation of HttpClient by HttpURLConnection. This is the recommended HTTP client in Android. Compared to ApacheHttpClient, it has one limitation. When handling 'Expected 100-continue' header, it only accepts either 100 continue or 417 reject, and throws ProtocolException on other status code. Such limitation will cause some issue when talking to S3 service. See S3's Put Object API for the requirement of handling 100-continue.
[中]通过HttpURLConnection实现HttpClient。这是Android中推荐的HTTP客户端。与ApacheHttpClient相比,它有一个局限性。当处理'Expected 100 continue'头时,它只接受100 continue或417 reject,并对其他状态代码抛出ProtocolException。这种限制在与S3服务交谈时会引起一些问题。有关处理100 continue的要求,请参见{$0$}。

代码示例

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

/**
 * Constructs a new AmazonWebServiceClient object using the specified
 * configuration.
 *
 * @param clientConfiguration The client configuration for this client.
 */
protected AmazonWebServiceClient(
    final ClientConfiguration clientConfiguration) {
  this(clientConfiguration, new UrlHttpClient(clientConfiguration));
}

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

/**
 * Needed to pass UrlHttpClientTest.
 *
 * @see #applyHeadersAndMethod(HttpRequest, HttpURLConnection, CurlBuilder)
 */
HttpURLConnection applyHeadersAndMethod(final HttpRequest request,
    final HttpURLConnection connection) throws ProtocolException {
  return applyHeadersAndMethod(request, connection, null /* curlBuilder */);
}

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

@Override
public HttpResponse execute(final HttpRequest request) throws IOException {
  final URL url = request.getUri().toURL();
  final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  final CurlBuilder curlBuilder = config.isCurlLogging()
      ? new CurlBuilder(request.getUri().toURL()) : null;
  configureConnection(request, connection);
  applyHeadersAndMethod(request, connection, curlBuilder);
  writeContentToConnection(request, connection, curlBuilder);
  if (curlBuilder != null) {
    if (curlBuilder.isValid()) {
      printToLog(curlBuilder.build());
    } else {
      printToLog("Failed to create curl, content too long");
    }
  }
  return createHttpResponse(request, connection);
}

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

@Override
public HttpResponse execute(final HttpRequest request) throws IOException {
  final URL url = request.getUri().toURL();
  final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  final CurlBuilder curlBuilder = config.isCurlLogging()
      ? new CurlBuilder(request.getUri().toURL()) : null;
  configureConnection(request, connection);
  applyHeadersAndMethod(request, connection, curlBuilder);
  writeContentToConnection(request, connection, curlBuilder);
  if (curlBuilder != null) {
    if (curlBuilder.isValid()) {
      printToLog(curlBuilder.build());
    } else {
      printToLog("Failed to create curl, content too long");
    }
  }
  return createHttpResponse(request, connection);
}

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

/**
 * Constructs a new AWS client using the specified client configuration
 * options (ex: max retry attempts, proxy settings, etc).
 *
 * @param config Configuration options specifying how this client will
 *            communicate with AWS (ex: proxy settings, retry count, etc.).
 */
public AmazonHttpClient(ClientConfiguration config) {
  this(config, new UrlHttpClient(config));
}

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

@Override
public HttpResponse execute(final HttpRequest request) throws IOException {
  final URL url = request.getUri().toURL();
  final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  final CurlBuilder curlBuilder = config.isCurlLogging()
      ? new CurlBuilder(request.getUri().toURL()) : null;
  configureConnection(request, connection);
  applyHeadersAndMethod(request, connection, curlBuilder);
  writeContentToConnection(request, connection, curlBuilder);
  if (curlBuilder != null) {
    if (curlBuilder.isValid()) {
      printToLog(curlBuilder.build());
    } else {
      printToLog("Failed to create curl, content too long");
    }
  }
  return createHttpResponse(request, connection);
}

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

/**
 * Needed to pass UrlHttpClientTest.
 *
 * @see #applyHeadersAndMethod(HttpRequest, HttpURLConnection, CurlBuilder)
 */
HttpURLConnection applyHeadersAndMethod(final HttpRequest request,
    final HttpURLConnection connection) throws ProtocolException {
  return applyHeadersAndMethod(request, connection, null /* curlBuilder */);
}

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

/**
 * Constructs a new Amazon S3 client using the specified AWS credentials and
 * client configuration to access Amazon S3.
 *
 * @param credentialsProvider The AWS credentials provider which will
 *            provide credentials to authenticate requests with AWS
 *            services.
 * @param clientConfiguration The client configuration options controlling
 *            how this client connects to Amazon S3 (e.g. proxy settings,
 *            retry counts, etc).
 */
public AmazonS3Client(AWSCredentialsProvider credentialsProvider,
           ClientConfiguration clientConfiguration) {
  this(credentialsProvider, clientConfiguration, new UrlHttpClient(clientConfiguration));
}

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

/**
 * Needed to pass UrlHttpClientTest.
 *
 * @see #applyHeadersAndMethod(HttpRequest, HttpURLConnection, CurlBuilder)
 */
HttpURLConnection applyHeadersAndMethod(final HttpRequest request,
    final HttpURLConnection connection) throws ProtocolException {
  return applyHeadersAndMethod(request, connection, null /* curlBuilder */);
}

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

/**
 * Constructs a new client to invoke service methods on
 * AmazonSimpleDB using the specified AWS account credentials
 * provider and client configuration options.
 *
 * <p>
 * All service calls made using this new client object are blocking, and will not
 * return until the service call completes.
 *
 * @param awsCredentialsProvider
 *            The AWS credentials provider which will provide credentials
 *            to authenticate requests with AWS services.
 * @param clientConfiguration The client configuration options controlling how this
 *                       client connects to AmazonSimpleDB
 *                       (ex: proxy settings, retry counts, etc.).
 */
public AmazonSimpleDBClient(AWSCredentialsProvider awsCredentialsProvider,
    ClientConfiguration clientConfiguration) {
  this(awsCredentialsProvider, clientConfiguration, new UrlHttpClient(clientConfiguration));
}

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

/**
 * Constructs a new client to invoke service methods on
 * AmazonEC2 using the specified AWS account credentials
 * provider and client configuration options.
 *
 * <p>
 * All service calls made using this new client object are blocking, and will not
 * return until the service call completes.
 *
 * @param awsCredentialsProvider
 *            The AWS credentials provider which will provide credentials
 *            to authenticate requests with AWS services.
 * @param clientConfiguration The client configuration options controlling how this
 *                       client connects to AmazonEC2
 *                       (ex: proxy settings, retry counts, etc.).
 */
public AmazonEC2Client(AWSCredentialsProvider awsCredentialsProvider,
    ClientConfiguration clientConfiguration) {
  this(awsCredentialsProvider, clientConfiguration, new UrlHttpClient(clientConfiguration));
}

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

/**
 * Constructs a new client to invoke service methods on AmazonCloudWatch
 * using the specified AWS account credentials provider and client
 * configuration options.
 * <p>
 * If AWS session credentials are passed in, then those credentials will be
 * used to authenticate requests. Otherwise, if AWS long-term credentials
 * are passed in, then session management will be handled automatically by
 * the SDK. Callers are encouraged to use long-term credentials and let the
 * SDK handle starting and renewing sessions.
 * <p>
 * Automatically managed sessions will be shared among all clients that use
 * the same credentials and service endpoint. To opt out of this behavior,
 * explicitly provide an instance of {@link AWSCredentialsProvider} that
 * returns {@link AWSSessionCredentials}.
 * <p>
 * All service calls made using this new client object are blocking, and
 * will not return until the service call completes.
 *
 * @param awsCredentialsProvider The AWS credentials provider which will
 *            provide credentials to authenticate requests with AWS
 *            services.
 * @param clientConfiguration The client configuration options controlling
 *            how this client connects to AmazonCloudWatch (ex: proxy
 *            settings, retry counts, etc.).
 */
public AmazonCloudWatchClient(AWSCredentialsProvider awsCredentialsProvider,
    ClientConfiguration clientConfiguration) {
  this(awsCredentialsProvider, clientConfiguration, new UrlHttpClient(clientConfiguration));
}

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

/**
 * Constructs a new client to invoke service methods on AmazonPolly using
 * the specified AWS account credentials provider and client configuration
 * options.
 * <p>
 * If AWS session credentials are passed in, then those credentials will be
 * used to authenticate requests. Otherwise, if AWS long-term credentials
 * are passed in, then session management will be handled automatically by
 * the SDK. Callers are encouraged to use long-term credentials and let the
 * SDK handle starting and renewing sessions.
 * <p>
 * Automatically managed sessions will be shared among all clients that use
 * the same credentials and service endpoint. To opt out of this behavior,
 * explicitly provide an instance of {@link AWSCredentialsProvider} that
 * returns {@link AWSSessionCredentials}.
 * <p>
 * All service calls made using this new client object are blocking, and
 * will not return until the service call completes.
 *
 * @param awsCredentialsProvider The AWS credentials provider which will
 *            provide credentials to authenticate requests with AWS
 *            services.
 * @param clientConfiguration The client configuration options controlling
 *            how this client connects to AmazonPolly (ex: proxy settings,
 *            retry counts, etc.).
 */
public AmazonPollyClient(AWSCredentialsProvider awsCredentialsProvider,
    ClientConfiguration clientConfiguration) {
  this(awsCredentialsProvider, clientConfiguration, new UrlHttpClient(clientConfiguration));
}

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

/**
 * Constructs a new client to invoke service methods on
 * AmazonMachineLearning using the specified AWS account credentials
 * provider and client configuration options.
 * <p>
 * If AWS session credentials are passed in, then those credentials will be
 * used to authenticate requests. Otherwise, if AWS long-term credentials
 * are passed in, then session management will be handled automatically by
 * the SDK. Callers are encouraged to use long-term credentials and let the
 * SDK handle starting and renewing sessions.
 * <p>
 * Automatically managed sessions will be shared among all clients that use
 * the same credentials and service endpoint. To opt out of this behavior,
 * explicitly provide an instance of {@link AWSCredentialsProvider} that
 * returns {@link AWSSessionCredentials}.
 * <p>
 * All service calls made using this new client object are blocking, and
 * will not return until the service call completes.
 *
 * @param awsCredentialsProvider The AWS credentials provider which will
 *            provide credentials to authenticate requests with AWS
 *            services.
 * @param clientConfiguration The client configuration options controlling
 *            how this client connects to AmazonMachineLearning (ex: proxy
 *            settings, retry counts, etc.).
 */
public AmazonMachineLearningClient(AWSCredentialsProvider awsCredentialsProvider,
    ClientConfiguration clientConfiguration) {
  this(awsCredentialsProvider, clientConfiguration, new UrlHttpClient(clientConfiguration));
}

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

/**
 * Constructs a new AmazonWebServiceClient object using the specified
 * configuration and request metric collector.
 *
 * @param clientConfiguration The client configuration for this client.
 * @param requestMetricCollector optional request metric collector to be
 *            used at the http client level; can be null.
 */
@Deprecated
protected AmazonWebServiceClient(
    final ClientConfiguration clientConfiguration,
    final RequestMetricCollector requestMetricCollector) {
  this(clientConfiguration, new UrlHttpClient(clientConfiguration), null);
}

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

/**
 * Constructs a new client to invoke service methods on
 * AmazonElasticLoadBalancing using the specified AWS account credentials
 * provider and client configuration options.
 * <p>
 * If AWS session credentials are passed in, then those credentials will be
 * used to authenticate requests. Otherwise, if AWS long-term credentials
 * are passed in, then session management will be handled automatically by
 * the SDK. Callers are encouraged to use long-term credentials and let the
 * SDK handle starting and renewing sessions.
 * <p>
 * Automatically managed sessions will be shared among all clients that use
 * the same credentials and service endpoint. To opt out of this behavior,
 * explicitly provide an instance of {@link AWSCredentialsProvider} that
 * returns {@link AWSSessionCredentials}.
 * <p>
 * All service calls made using this new client object are blocking, and
 * will not return until the service call completes.
 *
 * @param awsCredentialsProvider The AWS credentials provider which will
 *            provide credentials to authenticate requests with AWS
 *            services.
 * @param clientConfiguration The client configuration options controlling
 *            how this client connects to AmazonElasticLoadBalancing (ex:
 *            proxy settings, retry counts, etc.).
 */
public AmazonElasticLoadBalancingClient(AWSCredentialsProvider awsCredentialsProvider,
    ClientConfiguration clientConfiguration) {
  this(awsCredentialsProvider, clientConfiguration, new UrlHttpClient(clientConfiguration));
}

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

/**
 * Constructs a new client to invoke service methods on
 * AmazonSimpleEmailService using the specified AWS account credentials
 * provider and client configuration options.
 * <p>
 * If AWS session credentials are passed in, then those credentials will be
 * used to authenticate requests. Otherwise, if AWS long-term credentials
 * are passed in, then session management will be handled automatically by
 * the SDK. Callers are encouraged to use long-term credentials and let the
 * SDK handle starting and renewing sessions.
 * <p>
 * Automatically managed sessions will be shared among all clients that use
 * the same credentials and service endpoint. To opt out of this behavior,
 * explicitly provide an instance of {@link AWSCredentialsProvider} that
 * returns {@link AWSSessionCredentials}.
 * <p>
 * All service calls made using this new client object are blocking, and
 * will not return until the service call completes.
 *
 * @param awsCredentialsProvider The AWS credentials provider which will
 *            provide credentials to authenticate requests with AWS
 *            services.
 * @param clientConfiguration The client configuration options controlling
 *            how this client connects to AmazonSimpleEmailService (ex:
 *            proxy settings, retry counts, etc.).
 */
public AmazonSimpleEmailServiceClient(AWSCredentialsProvider awsCredentialsProvider,
    ClientConfiguration clientConfiguration) {
  this(awsCredentialsProvider, clientConfiguration, new UrlHttpClient(clientConfiguration));
}

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

/**
 * Constructs a new client to invoke service methods on AmazonCognitoSync
 * using the specified AWS account credentials provider and client
 * configuration options.
 * <p>
 * If AWS session credentials are passed in, then those credentials will be
 * used to authenticate requests. Otherwise, if AWS long-term credentials
 * are passed in, then session management will be handled automatically by
 * the SDK. Callers are encouraged to use long-term credentials and let the
 * SDK handle starting and renewing sessions.
 * <p>
 * Automatically managed sessions will be shared among all clients that use
 * the same credentials and service endpoint. To opt out of this behavior,
 * explicitly provide an instance of {@link AWSCredentialsProvider} that
 * returns {@link AWSSessionCredentials}.
 * <p>
 * All service calls made using this new client object are blocking, and
 * will not return until the service call completes.
 *
 * @param awsCredentialsProvider The AWS credentials provider which will
 *            provide credentials to authenticate requests with AWS
 *            services.
 * @param clientConfiguration The client configuration options controlling
 *            how this client connects to AmazonCognitoSync (ex: proxy
 *            settings, retry counts, etc.).
 */
public AmazonCognitoSyncClient(AWSCredentialsProvider awsCredentialsProvider,
    ClientConfiguration clientConfiguration) {
  this(awsCredentialsProvider, clientConfiguration, new UrlHttpClient(clientConfiguration));
}

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

/**
 * Constructs a new client to invoke service methods on AmazonDynamoDB using
 * the specified AWS account credentials provider and client configuration
 * options.
 * <p>
 * If AWS session credentials are passed in, then those credentials will be
 * used to authenticate requests. Otherwise, if AWS long-term credentials
 * are passed in, then session management will be handled automatically by
 * the SDK. Callers are encouraged to use long-term credentials and let the
 * SDK handle starting and renewing sessions.
 * <p>
 * Automatically managed sessions will be shared among all clients that use
 * the same credentials and service endpoint. To opt out of this behavior,
 * explicitly provide an instance of {@link AWSCredentialsProvider} that
 * returns {@link AWSSessionCredentials}.
 * <p>
 * All service calls made using this new client object are blocking, and
 * will not return until the service call completes.
 *
 * @param awsCredentialsProvider The AWS credentials provider which will
 *            provide credentials to authenticate requests with AWS
 *            services.
 * @param clientConfiguration The client configuration options controlling
 *            how this client connects to AmazonDynamoDB (ex: proxy
 *            settings, retry counts, etc.).
 */
public AmazonDynamoDBClient(AWSCredentialsProvider awsCredentialsProvider,
    ClientConfiguration clientConfiguration) {
  this(awsCredentialsProvider, clientConfiguration, new UrlHttpClient(clientConfiguration));
}

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

/**
 * Constructs a new client to invoke service methods on AmazonKinesis using
 * the specified AWS account credentials provider and client configuration
 * options.
 * <p>
 * If AWS session credentials are passed in, then those credentials will be
 * used to authenticate requests. Otherwise, if AWS long-term credentials
 * are passed in, then session management will be handled automatically by
 * the SDK. Callers are encouraged to use long-term credentials and let the
 * SDK handle starting and renewing sessions.
 * <p>
 * Automatically managed sessions will be shared among all clients that use
 * the same credentials and service endpoint. To opt out of this behavior,
 * explicitly provide an instance of {@link AWSCredentialsProvider} that
 * returns {@link AWSSessionCredentials}.
 * <p>
 * All service calls made using this new client object are blocking, and
 * will not return until the service call completes.
 *
 * @param awsCredentialsProvider The AWS credentials provider which will
 *            provide credentials to authenticate requests with AWS
 *            services.
 * @param clientConfiguration The client configuration options controlling
 *            how this client connects to AmazonKinesis (ex: proxy settings,
 *            retry counts, etc.).
 */
public AmazonKinesisClient(AWSCredentialsProvider awsCredentialsProvider,
    ClientConfiguration clientConfiguration) {
  this(awsCredentialsProvider, clientConfiguration, new UrlHttpClient(clientConfiguration));
}

相关文章