• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HttpMethodName类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.http.HttpMethodName的典型用法代码示例。如果您正苦于以下问题:Java HttpMethodName类的具体用法?Java HttpMethodName怎么用?Java HttpMethodName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpMethodName类属于com.amazonaws.http包,在下文中一共展示了HttpMethodName类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testExecute_noApiKey_noCreds

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Test
public void testExecute_noApiKey_noCreds() throws IOException {
    client = new GenericApiGatewayClientBuilder()
            .withEndpoint("https://foobar.execute-api.us-east-1.amazonaws.com")
            .withRegion(Region.getRegion(Regions.fromName("us-east-1")))
            .withClientConfiguration(new ClientConfiguration())
            .withHttpClient(new AmazonHttpClient(new ClientConfiguration(), mockClient, null))
            .build();

    GenericApiGatewayResponse response = client.execute(
            new GenericApiGatewayRequestBuilder()
                    .withBody(new ByteArrayInputStream("test request".getBytes()))
                    .withHttpMethod(HttpMethodName.POST)
                    .withResourcePath("/test/orders").build());

    assertEquals("Wrong response body", "test payload", response.getBody());
    assertEquals("Wrong response status", 200, response.getHttpResponse().getStatusCode());

    Mockito.verify(mockClient, times(1)).execute(argThat(new LambdaMatcher<>(
                    x -> (x.getMethod().equals("POST")
                            && x.getFirstHeader("x-api-key") == null
                            && x.getFirstHeader("Authorization") == null
                            && x.getURI().toString().equals("https://foobar.execute-api.us-east-1.amazonaws.com/test/orders")))),
            any(HttpContext.class));
}
 
开发者ID:rpgreen,项目名称:apigateway-generic-java-sdk,代码行数:26,代码来源:GenericApiGatewayClientTest.java


示例2: listObjects

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Override
public ObjectListing listObjects(ListObjectsRequest listObjectsRequest)
        throws SdkClientException, AmazonServiceException {
    listObjectsRequest = beforeClientExecution(listObjectsRequest);
    rejectNull(listObjectsRequest.getBucketName(), "The bucket name parameter must be specified when listing objects in a bucket");

    /**
     * This flag shows whether we need to url decode S3 key names. This flag is enabled
     * only when the customers don't explicitly call {@link ListObjectsRequest#setEncodingType(String)},
     * otherwise, it will be disabled for maintaining backwards compatibility.
     */
    final boolean shouldSDKDecodeResponse = listObjectsRequest.getEncodingType() == null;

    Request<ListObjectsRequest> request = createRequest(listObjectsRequest.getBucketName(), null, listObjectsRequest, HttpMethodName.GET);
    addParameterIfNotNull(request, "prefix", listObjectsRequest.getPrefix());
    addParameterIfNotNull(request, "marker", listObjectsRequest.getMarker());
    addParameterIfNotNull(request, "delimiter", listObjectsRequest.getDelimiter());
    if (listObjectsRequest.getMaxKeys() != null && listObjectsRequest.getMaxKeys().intValue() >= 0) request.addParameter("max-keys", listObjectsRequest.getMaxKeys().toString());
    request.addParameter("encoding-type", shouldSDKDecodeResponse ? Constants.URL_ENCODING : listObjectsRequest.getEncodingType());

    return invoke(request, new Unmarshallers.ListObjectsUnmarshaller(shouldSDKDecodeResponse), listObjectsRequest.getBucketName(), null);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:23,代码来源:AmazonS3Client.java


示例3: testExecute_happy

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Test
public void testExecute_happy() throws IOException {
    Map<String, String> headers = new HashMap<>();
    headers.put("Account-Id", "fubar");
    headers.put("Content-Type", "application/json");
    GenericApiGatewayResponse response = client.execute(
            new GenericApiGatewayRequestBuilder()
                    .withBody(new ByteArrayInputStream("test request".getBytes()))
                    .withHttpMethod(HttpMethodName.POST)
                    .withHeaders(headers)
                    .withResourcePath("/test/orders").build());

    assertEquals("Wrong response body", "test payload", response.getBody());
    assertEquals("Wrong response status", 200, response.getHttpResponse().getStatusCode());

    Mockito.verify(mockClient, times(1)).execute(argThat(new LambdaMatcher<>(
                    x -> (x.getMethod().equals("POST")
                            && x.getFirstHeader("Account-Id").getValue().equals("fubar")
                            && x.getFirstHeader("x-api-key").getValue().equals("12345")
                            && x.getFirstHeader("Authorization").getValue().startsWith("AWS4")
                            && x.getURI().toString().equals("https://foobar.execute-api.us-east-1.amazonaws.com/test/orders")))),
            any(HttpContext.class));
}
 
开发者ID:rpgreen,项目名称:apigateway-generic-java-sdk,代码行数:24,代码来源:GenericApiGatewayClientTest.java


示例4: testExecute_non2xx_exception

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Test
public void testExecute_non2xx_exception() throws IOException {
    HttpResponse resp = new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, 404, "Not found"));
    BasicHttpEntity entity = new BasicHttpEntity();
    entity.setContent(new ByteArrayInputStream("{\"message\" : \"error payload\"}".getBytes()));
    resp.setEntity(entity);
    Mockito.doReturn(resp).when(mockClient).execute(any(HttpUriRequest.class), any(HttpContext.class));

    Map<String, String> headers = new HashMap<>();
    headers.put("Account-Id", "fubar");
    headers.put("Content-Type", "application/json");

    try {
        client.execute(
                new GenericApiGatewayRequestBuilder()
                        .withBody(new ByteArrayInputStream("test request".getBytes()))
                        .withHttpMethod(HttpMethodName.POST)
                        .withHeaders(headers)
                        .withResourcePath("/test/orders").build());

        Assert.fail("Expected exception");
    } catch (GenericApiGatewayException e) {
        assertEquals("Wrong status code", 404, e.getStatusCode());
        assertEquals("Wrong exception message", "{\"message\":\"error payload\"}", e.getErrorMessage());
    }
}
 
开发者ID:rpgreen,项目名称:apigateway-generic-java-sdk,代码行数:27,代码来源:GenericApiGatewayClientTest.java


示例5: addRequestConfig

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
private void addRequestConfig(final HttpRequestBase base,
                              final Request<?> request,
                              final HttpClientSettings settings) {
    final RequestConfig.Builder requestConfigBuilder = RequestConfig
            .custom()
            .setConnectionRequestTimeout(settings.getConnectionPoolRequestTimeout())
            .setConnectTimeout(settings.getConnectionTimeout())
            .setSocketTimeout(settings.getSocketTimeout())
            .setLocalAddress(settings.getLocalAddress());

    /*
     * Enable 100-continue support for PUT operations, since this is
     * where we're potentially uploading large amounts of data and want
     * to find out as early as possible if an operation will fail. We
     * don't want to do this for all operations since it will cause
     * extra latency in the network interaction.
     */
    if (HttpMethodName.PUT == request.getHttpMethod() && settings.isUseExpectContinue()) {
        requestConfigBuilder.setExpectContinueEnabled(true);
    }

    addProxyConfig(requestConfigBuilder, settings);

    base.setConfig(requestConfigBuilder.build());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:26,代码来源:ApacheHttpRequestFactory.java


示例6: clientExecutionTimeoutEnabled_aborted_exception_occurs_timeout_expired

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Test(expected = ClientExecutionTimeoutException.class)
public void
clientExecutionTimeoutEnabled_aborted_exception_occurs_timeout_expired()
        throws Exception {
    ClientConfiguration config = new ClientConfiguration()
            .withClientExecutionTimeout(CLIENT_EXECUTION_TIMEOUT)
            .withMaxErrorRetry(0);
    ConnectionManagerAwareHttpClient rawHttpClient =
            createRawHttpClientSpy(config);

    httpClient = new AmazonHttpClient(config, rawHttpClient, null);

    execute(httpClient, new EmptyHttpRequest(server.getEndpoint(),
            HttpMethodName.PUT, new SdkBufferedInputStream(new InputStream() {
        @Override
        public int read() throws IOException {
            // Sleeping here to avoid OOM issues from a limitless InputStream
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
            return 1;
        }
    })));
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:27,代码来源:AbortedExceptionClientExecutionTimerIntegrationTest.java


示例7: request_has_proxy_config_when_proxy_auth_enabled

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Test
public void request_has_proxy_config_when_proxy_auth_enabled() throws Exception {
    List<ProxyAuthenticationMethod> authMethods = Arrays.asList(ProxyAuthenticationMethod.BASIC,
                                                                ProxyAuthenticationMethod.DIGEST,
                                                                ProxyAuthenticationMethod.KERBEROS,
                                                                ProxyAuthenticationMethod.NTLM,
                                                                ProxyAuthenticationMethod.SPNEGO);
    List<String> expectedAuthMethods = Arrays.asList(AuthSchemes.BASIC,
                                                     AuthSchemes.DIGEST,
                                                     AuthSchemes.KERBEROS,
                                                     AuthSchemes.NTLM,
                                                     AuthSchemes.SPNEGO);

    ClientConfiguration configuration = new ClientConfiguration().withProxyHost("localhost")
                                                                 .withProxyPort(80)
                                                                 .withProxyUsername("user")
                                                                 .withProxyPassword("password")
                                                                 .withProxyAuthenticationMethods(authMethods);
    HttpClientSettings settings = HttpClientSettings.adapt(configuration);
    HttpRequestBase requestBase = requestFactory.create(newDefaultRequest(HttpMethodName.POST), settings);
    Assert.assertEquals(expectedAuthMethods, requestBase.getConfig().getProxyPreferredAuthSchemes());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:23,代码来源:ApacheDefaultHttpRequestFactoryTest.java


示例8: listVersions

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Override
public VersionListing listVersions(ListVersionsRequest listVersionsRequest)
        throws SdkClientException, AmazonServiceException {
    listVersionsRequest = beforeClientExecution(listVersionsRequest);
    rejectNull(listVersionsRequest.getBucketName(), "The bucket name parameter must be specified when listing versions in a bucket");

    /**
     * This flag shows whether we need to url decode S3 key names. This flag is enabled
     * only when the customers don't explicitly call {@link listVersionsRequest#setEncodingType(String)},
     * otherwise, it will be disabled for maintaining backwards compatibility.
     */
    final boolean shouldSDKDecodeResponse = listVersionsRequest.getEncodingType() == null;

    Request<ListVersionsRequest> request = createRequest(listVersionsRequest.getBucketName(), null, listVersionsRequest, HttpMethodName.GET);
    request.addParameter("versions", null);

    addParameterIfNotNull(request, "prefix", listVersionsRequest.getPrefix());
    addParameterIfNotNull(request, "key-marker", listVersionsRequest.getKeyMarker());
    addParameterIfNotNull(request, "version-id-marker", listVersionsRequest.getVersionIdMarker());
    addParameterIfNotNull(request, "delimiter", listVersionsRequest.getDelimiter());

    if (listVersionsRequest.getMaxResults() != null && listVersionsRequest.getMaxResults() >= 0) request.addParameter("max-keys", listVersionsRequest.getMaxResults().toString());
    request.addParameter("encoding-type", shouldSDKDecodeResponse ? Constants.URL_ENCODING : listVersionsRequest.getEncodingType());

    return invoke(request, new Unmarshallers.VersionListUnmarshaller(shouldSDKDecodeResponse), listVersionsRequest.getBucketName(), null);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:27,代码来源:AmazonS3Client.java


示例9: listBuckets

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Override
public List<Bucket> listBuckets(ListBucketsRequest listBucketsRequest)
        throws SdkClientException, AmazonServiceException {
    listBucketsRequest = beforeClientExecution(listBucketsRequest);
    rejectNull(listBucketsRequest, "The request object parameter listBucketsRequest must be specified.");
    Request<ListBucketsRequest> request = createRequest(null, null, listBucketsRequest, HttpMethodName.GET);
    
    //Add IBM Service Instance Id to headers
	if ((null != this.awsCredentialsProvider ) && (this.awsCredentialsProvider.getCredentials() instanceof IBMOAuthCredentials)) {
		IBMOAuthCredentials oAuthCreds = (IBMOAuthCredentials)this.awsCredentialsProvider.getCredentials();
		if (oAuthCreds.getServiceInstanceId() != null) {
        	request.addHeader(Headers.IBM_SERVICE_INSTANCE_ID, oAuthCreds.getServiceInstanceId());	
		}
	}
    
    return invoke(request, new Unmarshallers.ListBucketsUnmarshaller(), null, null);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:18,代码来源:AmazonS3Client.java


示例10: getObjectMetadata

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest)
        throws SdkClientException, AmazonServiceException {
    getObjectMetadataRequest = beforeClientExecution(getObjectMetadataRequest);
    rejectNull(getObjectMetadataRequest, "The GetObjectMetadataRequest parameter must be specified when requesting an object's metadata");

    String bucketName = getObjectMetadataRequest.getBucketName();
    String key = getObjectMetadataRequest.getKey();
    String versionId = getObjectMetadataRequest.getVersionId();

    rejectNull(bucketName, "The bucket name parameter must be specified when requesting an object's metadata");
    rejectNull(key, "The key parameter must be specified when requesting an object's metadata");

    Request<GetObjectMetadataRequest> request = createRequest(bucketName, key, getObjectMetadataRequest, HttpMethodName.HEAD);

    if (versionId != null) request.addParameter("versionId", versionId);

    populateRequesterPaysHeader(request, getObjectMetadataRequest.isRequesterPays());
    addPartNumberIfNotNull(request, getObjectMetadataRequest.getPartNumber());

    populateSSE_C(request, getObjectMetadataRequest.getSSECustomerKey());

    return invoke(request, new S3MetadataResponseHandler(), bucketName, key);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:25,代码来源:AmazonS3Client.java


示例11: deleteVersion

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Override
public void deleteVersion(DeleteVersionRequest deleteVersionRequest)
        throws SdkClientException, AmazonServiceException {
    deleteVersionRequest = beforeClientExecution(deleteVersionRequest);
    rejectNull(deleteVersionRequest,
        "The delete version request object must be specified when deleting a version");

    String bucketName = deleteVersionRequest.getBucketName();
    String key = deleteVersionRequest.getKey();
    String versionId = deleteVersionRequest.getVersionId();

    rejectNull(bucketName, "The bucket name must be specified when deleting a version");
    rejectNull(key, "The key must be specified when deleting a version");
    rejectNull(versionId, "The version ID must be specified when deleting a version");

    Request<DeleteVersionRequest> request = createRequest(bucketName, key, deleteVersionRequest, HttpMethodName.DELETE);
    if (versionId != null) request.addParameter("versionId", versionId);

    if (deleteVersionRequest.getMfa() != null) {
        populateRequestWithMfaDetails(request, deleteVersionRequest.getMfa());
    }

    invoke(request, voidResponseHandler, bucketName, key);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:25,代码来源:AmazonS3Client.java


示例12: getBucketCrossOriginConfiguration

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Override
public BucketCrossOriginConfiguration getBucketCrossOriginConfiguration(GetBucketCrossOriginConfigurationRequest getBucketCrossOriginConfigurationRequest) {
    getBucketCrossOriginConfigurationRequest = beforeClientExecution(getBucketCrossOriginConfigurationRequest);
    rejectNull(getBucketCrossOriginConfigurationRequest, "The request object parameter getBucketCrossOriginConfigurationRequest must be specified.");
    String bucketName = getBucketCrossOriginConfigurationRequest.getBucketName();
    rejectNull(bucketName, "The bucket name must be specified when retrieving the bucket cross origin configuration.");

    Request<GetBucketCrossOriginConfigurationRequest> request = createRequest(bucketName, null, getBucketCrossOriginConfigurationRequest, HttpMethodName.GET);
    request.addParameter("cors", null);

    try {
        return invoke(request, new Unmarshallers.BucketCrossOriginConfigurationUnmarshaller(), bucketName, null);
    } catch (AmazonServiceException ase) {
        switch (ase.getStatusCode()) {
        case 404:
            return null;
        default:
            throw ase;
        }
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:22,代码来源:AmazonS3Client.java


示例13: getBucketTaggingConfiguration

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Override
public BucketTaggingConfiguration getBucketTaggingConfiguration(GetBucketTaggingConfigurationRequest getBucketTaggingConfigurationRequest) {
    getBucketTaggingConfigurationRequest = beforeClientExecution(getBucketTaggingConfigurationRequest);
    rejectNull(getBucketTaggingConfigurationRequest, "The request object parameter getBucketTaggingConfigurationRequest must be specifed.");
    String bucketName = getBucketTaggingConfigurationRequest.getBucketName();
    rejectNull(bucketName, "The bucket name must be specified when retrieving the bucket tagging configuration.");

    Request<GetBucketTaggingConfigurationRequest> request = createRequest(bucketName, null, getBucketTaggingConfigurationRequest, HttpMethodName.GET);
    request.addParameter("tagging", null);

    try {
        return invoke(request, new Unmarshallers.BucketTaggingConfigurationUnmarshaller(), bucketName, null);
    } catch (AmazonServiceException ase) {
        switch (ase.getStatusCode()) {
        case 404:
            return null;
        default:
            throw ase;
        }
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:22,代码来源:AmazonS3Client.java


示例14: deleteBucketTaggingConfiguration

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Override
public void deleteBucketTaggingConfiguration(
        DeleteBucketTaggingConfigurationRequest deleteBucketTaggingConfigurationRequest) {
    deleteBucketTaggingConfigurationRequest = beforeClientExecution(deleteBucketTaggingConfigurationRequest);
    rejectNull(deleteBucketTaggingConfigurationRequest,
            "The delete bucket tagging configuration request object must be specified.");

    String bucketName = deleteBucketTaggingConfigurationRequest.getBucketName();
    rejectNull(bucketName,
            "The bucket name parameter must be specified when deleting bucket tagging configuration.");

    Request<DeleteBucketTaggingConfigurationRequest> request = createRequest(bucketName, null, deleteBucketTaggingConfigurationRequest, HttpMethodName.DELETE);
    request.addParameter("tagging", null);

    invoke(request, voidResponseHandler, bucketName, null);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:17,代码来源:AmazonS3Client.java


示例15: abortMultipartUpload

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest)
        throws SdkClientException, AmazonServiceException {
    abortMultipartUploadRequest = beforeClientExecution(abortMultipartUploadRequest);
    rejectNull(abortMultipartUploadRequest,
        "The request parameter must be specified when aborting a multipart upload");
    rejectNull(abortMultipartUploadRequest.getBucketName(),
        "The bucket name parameter must be specified when aborting a multipart upload");
    rejectNull(abortMultipartUploadRequest.getKey(),
        "The key parameter must be specified when aborting a multipart upload");
    rejectNull(abortMultipartUploadRequest.getUploadId(),
        "The upload ID parameter must be specified when aborting a multipart upload");

    String bucketName = abortMultipartUploadRequest.getBucketName();
    String key = abortMultipartUploadRequest.getKey();

    Request<AbortMultipartUploadRequest> request = createRequest(bucketName, key, abortMultipartUploadRequest, HttpMethodName.DELETE);
    request.addParameter("uploadId", abortMultipartUploadRequest.getUploadId());
    populateRequesterPaysHeader(request, abortMultipartUploadRequest.isRequesterPays());

    invoke(request, voidResponseHandler, bucketName, key);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:23,代码来源:AmazonS3Client.java


示例16: listMultipartUploads

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
@Override
public MultipartUploadListing listMultipartUploads(ListMultipartUploadsRequest listMultipartUploadsRequest)
        throws SdkClientException, AmazonServiceException {
    listMultipartUploadsRequest = beforeClientExecution(listMultipartUploadsRequest);
    rejectNull(listMultipartUploadsRequest,
        "The request parameter must be specified when listing multipart uploads");

    rejectNull(listMultipartUploadsRequest.getBucketName(),
        "The bucket name parameter must be specified when listing multipart uploads");

    Request<ListMultipartUploadsRequest> request = createRequest(listMultipartUploadsRequest.getBucketName(), null, listMultipartUploadsRequest, HttpMethodName.GET);
    request.addParameter("uploads", null);

    if (listMultipartUploadsRequest.getKeyMarker() != null) request.addParameter("key-marker", listMultipartUploadsRequest.getKeyMarker());
    if (listMultipartUploadsRequest.getMaxUploads() != null) request.addParameter("max-uploads", listMultipartUploadsRequest.getMaxUploads().toString());
    if (listMultipartUploadsRequest.getUploadIdMarker() != null) request.addParameter("upload-id-marker", listMultipartUploadsRequest.getUploadIdMarker());
    if (listMultipartUploadsRequest.getDelimiter() != null) request.addParameter("delimiter", listMultipartUploadsRequest.getDelimiter());
    if (listMultipartUploadsRequest.getPrefix() != null) request.addParameter("prefix", listMultipartUploadsRequest.getPrefix());
    if (listMultipartUploadsRequest.getEncodingType() != null) request.addParameter("encoding-type", listMultipartUploadsRequest.getEncodingType());

    return invoke(request, new Unmarshallers.ListMultipartUploadsResultUnmarshaller(), listMultipartUploadsRequest.getBucketName(), null);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:23,代码来源:AmazonS3Client.java


示例17: createRequest

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
protected <X extends AmazonWebServiceRequest> Request<X> createRequest(String bucketName, String key, X originalRequest, HttpMethodName httpMethod, URI endpoint) {
    // If the underlying AmazonS3Client has enabled accelerate mode and the original
    // request operation is accelerate mode supported, then the request will use the
    // s3-accelerate endpoint to performe the operations.
    if (clientOptions.isAccelerateModeEnabled() && !(originalRequest instanceof S3AccelerateUnsupported)) {
        if (clientOptions.isDualstackEnabled()) {
            endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_DUALSTACK_HOSTNAME, clientConfiguration);
        } else {
            endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_HOSTNAME, clientConfiguration);
        }
    }

    Request<X> request = new DefaultRequest<X>(originalRequest, Constants.S3_SERVICE_DISPLAY_NAME);
    request.setHttpMethod(httpMethod);
    request.addHandlerContext(S3HandlerContextKeys.IS_CHUNKED_ENCODING_DISABLED,
            Boolean.valueOf(clientOptions.isChunkedEncodingDisabled()));
    request.addHandlerContext(S3HandlerContextKeys.IS_PAYLOAD_SIGNING_ENABLED,
            Boolean.valueOf(clientOptions.isPayloadSigningEnabled()));
    resolveRequestEndpoint(request, bucketName, key, endpoint);

    return request;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:23,代码来源:AmazonS3Client.java


示例18: getBucketRequestPayment

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
/**
 * Retrieves the request payment configuration for a given Amazon S3 bucket.
 * <p>
 * When the request payment configuration for a Amazon S3 bucket is
 * <code>Requester</code>, the requester instead of the bucket owner pays
 * the cost of the request and the data download from the bucket. The bucket
 * owner always pays the cost of storing data.
 */
private RequestPaymentConfiguration getBucketRequestPayment(
        GetRequestPaymentConfigurationRequest getRequestPaymentConfigurationRequest) {

    String bucketName = getRequestPaymentConfigurationRequest
            .getBucketName();

    rejectNull(
            bucketName,
            "The bucket name parameter must be specified while getting the Request Payment Configuration.");

    Request<GetRequestPaymentConfigurationRequest> request = createRequest(
            bucketName, null, getRequestPaymentConfigurationRequest,
            HttpMethodName.GET);
    request.addParameter("requestPayment", null);
    request.addHeader("Content-Type", "application/xml");

    return invoke(request,
            new Unmarshallers.RequestPaymentConfigurationUnmarshaller(),
            bucketName, null);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:29,代码来源:AmazonS3Client.java


示例19: getBucketRegionViaHeadRequest

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
/**
 * Retrieves the region of the bucket by making a HeadBucket request to us-west-1 region.
 *
 * Currently S3 doesn't return region in a HEAD Bucket request if the bucket
 * owner has enabled bucket to accept only SigV4 requests via bucket
 * policies.
 */
private String getBucketRegionViaHeadRequest(String bucketName) {
    String bucketRegion = null;

    try {
        Request<HeadBucketRequest> request = createRequest(bucketName, null,
                new HeadBucketRequest(bucketName), HttpMethodName.HEAD);

        HeadBucketResult result = invoke(request, new HeadBucketResultHandler(), bucketName, null, true);
        bucketRegion = result.getBucketRegion();
    } catch (AmazonS3Exception exception) {
        if (exception.getAdditionalDetails() != null) {
            bucketRegion = exception.getAdditionalDetails().get(
                Headers.S3_BUCKET_REGION);
        }
    }

    if (bucketRegion == null && log.isDebugEnabled()) {
        log.debug("Not able to derive region of the " + bucketName + " from the HEAD Bucket requests.");
    }

    return bucketRegion;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:30,代码来源:AmazonS3Client.java


示例20: performsRequest

import com.amazonaws.http.HttpMethodName; //导入依赖的package包/类
/**
 * AwsPost can perform the original {@link AwsHttpRequest}
 * @throws IOException If something goes wrong while reading
 *  the request's content.
 */
@Test
public void performsRequest() throws IOException {
    String jsonContent = "{\"testContent\":\"fake\"}";
    AwsPost<String> awsp = new AwsPost<>(
        new AwsHttpRequest.FakeAwsHttpRequest(),
        new ByteArrayInputStream(jsonContent.getBytes())
    );
    assertTrue(awsp.perform().equals("performed fake request"));
    assertTrue(awsp.request().getHttpMethod().equals(HttpMethodName.POST));

    StringWriter writer = new StringWriter();
    IOUtils.copy(awsp.request().getContent(), writer, "UTF-8");
    String content = writer.toString();

    assertTrue(content.equals(jsonContent));
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:22,代码来源:AwsPostTestCase.java



注:本文中的com.amazonaws.http.HttpMethodName类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ParserUtils类代码示例发布时间:2022-05-22
下一篇:
Java SafeModeInfo类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap