本文整理汇总了Java中com.amazonaws.http.HttpMethodName类的典型用法代码示例。如果您正苦于以下问题:Java HttpMethodName类的具体用法?Java HttpMethodName怎么用?Java HttpMethodName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpMethodName类属于com.amazonaws.http包,在下文中一共展示了HttpMethodName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例2: 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
示例3: 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);
}
示例4: 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));
}
示例5: 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());
}
}
示例6: 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());
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
}
示例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;
}
}
}
示例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);
}
示例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);
}