本文整理了Java中com.amazonaws.Request.getHeaders
方法的一些代码示例,展示了Request.getHeaders
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getHeaders
方法的具体详情如下:
包路径:com.amazonaws.Request
类名称:Request
方法名:getHeaders
[英]Returns a map of all the headers included in this request.
[中]返回此请求中包含的所有头的映射。
代码示例来源:origin: aws/aws-sdk-java
@Override
public void beforeRequest(Request<?> request) {
// Some operations marshall to this header, so don't clobber if it exists
if (!request.getHeaders().containsKey("Accept")) {
request.addHeader("Accept", "application/json");
}
}
代码示例来源:origin: aws/aws-sdk-java
@Override
public void beforeRequest(Request<?> request) {
request.addHeader("x-amz-glacier-version", "2012-06-01");
request.addHeader("x-amz-content-sha256", "required");
String contentLength = request.getHeaders().remove("x-amz-content-length");
if (contentLength != null) {
request.getHeaders().put("Content-Length", contentLength);
String range = request.getHeaders().get("Content-Range");
request.getHeaders().put("Content-Length", Long.toString(contentLength));
if (resourcePath != null) {
String newResourcePath = resourcePath.replace("{jobType}", "archive-retrievals");
request.setResourcePath(newResourcePath);
代码示例来源:origin: aws/aws-sdk-java
@Override
public Request<OrigRequest> finishMarshalling() {
// Content may already be set if the payload is binary data.
if (request.getContent() == null) {
// End the implicit request object if needed.
if (!hasExplicitPayloadMember) {
jsonGenerator.writeEndObject();
}
byte[] content = jsonGenerator.getBytes();
request.setContent(new ByteArrayInputStream(content));
if (content.length > 0) {
request.addHeader("Content-Length", Integer.toString(content.length));
}
}
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", contentType);
}
return request;
}
代码示例来源:origin: aws/aws-sdk-java
public Request<UpdateHostedZoneCommentRequest> marshall(UpdateHostedZoneCommentRequest updateHostedZoneCommentRequest) {
if (updateHostedZoneCommentRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
Request<UpdateHostedZoneCommentRequest> request = new DefaultRequest<UpdateHostedZoneCommentRequest>(updateHostedZoneCommentRequest, "AmazonRoute53");
request.setHttpMethod(HttpMethodName.POST);
String uriResourcePath = "/2013-04-01/hostedzone/{Id}";
uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall(uriResourcePath, "Id", updateHostedZoneCommentRequest.getId());
request.setResourcePath(uriResourcePath);
try {
StringWriter stringWriter = new StringWriter();
XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/");
xmlWriter.startElement("UpdateHostedZoneCommentRequest");
if (updateHostedZoneCommentRequest != null) {
if (updateHostedZoneCommentRequest.getComment() != null) {
xmlWriter.startElement("Comment").value(updateHostedZoneCommentRequest.getComment()).endElement();
}
}
xmlWriter.endElement();
request.setContent(new StringInputStream(stringWriter.getBuffer().toString()));
request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length));
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/xml");
}
} catch (Throwable t) {
throw new SdkClientException("Unable to marshall request to XML: " + t.getMessage(), t);
}
return request;
}
代码示例来源:origin: aws/aws-sdk-java
final Map<String, String> originalHeaders = new HashMap<String, String>(request.getHeaders());
request.setResourcePath(SdkHttpUtils.urlEncode(path, true));
awsRequestMetrics.addPropertyWith(Field.RedirectLocation,
redirectedURI.toString());
request.setParameters(originalParameters);
request.setHeaders(originalHeaders);
request.setContent(originalContent);
代码示例来源:origin: aws/aws-sdk-java
request.setResourcePath(uriResourcePath);
StringWriter stringWriter = new StringWriter();
XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/");
xmlWriter.startElement("HostedZoneId").value(createQueryLoggingConfigRequest.getHostedZoneId()).endElement();
xmlWriter.startElement("CloudWatchLogsLogGroupArn").value(createQueryLoggingConfigRequest.getCloudWatchLogsLogGroupArn()).endElement();
request.setContent(new StringInputStream(stringWriter.getBuffer().toString()));
request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length));
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/xml");
代码示例来源:origin: aws/aws-sdk-java
@Override
public Request<RawRequest> marshall(RawRequest rawRequestRequest) {
if (rawRequestRequest == null) {
throw new AmazonClientException("Invalid argument passed to marshall(...)");
}
Request<RawRequest> request = new DefaultRequest<>("MyService");
request.setHttpMethod(rawRequestRequest.httpMethod());
request.setResourcePath(rawRequestRequest.path());
request.setContent(rawRequestRequest.payload());
// Custom headers and query params are set later in the runtime
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", protocolFactory.getContentType());
}
return request;
}
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Apply the user agent to the marshalled request (if not already present). Appends a custom marker to track usage of the
* Netty based client.
*/
private void applyUserAgent(PutMediaRequest request, Request<PutMediaRequest> marshalled) {
if (!marshalled.getHeaders().containsKey("User-Agent")) {
marshalled.addHeader("User-Agent",
RuntimeHttpUtils.getUserAgent(new ClientConfiguration(),
request.getRequestClientOptions()
.getClientMarker(RequestClientOptions.Marker.USER_AGENT)));
}
}
代码示例来源:origin: aws/aws-sdk-java
request.setResourcePath(uriResourcePath);
StringWriter stringWriter = new StringWriter();
XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/");
xmlWriter.startElement("CallerReference").value(createReusableDelegationSetRequest.getCallerReference()).endElement();
xmlWriter.startElement("HostedZoneId").value(createReusableDelegationSetRequest.getHostedZoneId()).endElement();
request.setContent(new StringInputStream(stringWriter.getBuffer().toString()));
request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length));
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/xml");
代码示例来源:origin: aws-amplify/aws-sdk-android
public Request<DescribeLimitsRequest> marshall(DescribeLimitsRequest describeLimitsRequest) {
if (describeLimitsRequest == null) {
throw new AmazonClientException(
"Invalid argument passed to marshall(DescribeLimitsRequest)");
}
Request<DescribeLimitsRequest> request = new DefaultRequest<DescribeLimitsRequest>(
describeLimitsRequest, "AmazonDynamoDB");
String target = "DynamoDB_20120810.DescribeLimits";
request.addHeader("X-Amz-Target", target);
request.setHttpMethod(HttpMethodName.POST);
String uriResourcePath = "/";
request.setResourcePath(uriResourcePath);
request.addHeader("Content-Length", "0");
request.setContent(new ByteArrayInputStream(new byte[0]));
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/x-amz-json-1.0");
}
return request;
}
}
代码示例来源:origin: aws/aws-sdk-java
if (!request.getHeaders().containsKey(Headers.CONTENT_TYPE)) {
request.addHeader(Headers.CONTENT_TYPE,
"application/octet-stream");
代码示例来源:origin: aws/aws-sdk-java
uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall(uriResourcePath, "Version",
updateTrafficPolicyCommentRequest.getVersion());
request.setResourcePath(uriResourcePath);
StringWriter stringWriter = new StringWriter();
XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/");
xmlWriter.startElement("Comment").value(updateTrafficPolicyCommentRequest.getComment()).endElement();
request.setContent(new StringInputStream(stringWriter.getBuffer().toString()));
request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length));
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/xml");
代码示例来源:origin: aws-amplify/aws-sdk-android
public Request<DescribeEndpointsRequest> marshall(
DescribeEndpointsRequest describeEndpointsRequest) {
if (describeEndpointsRequest == null) {
throw new AmazonClientException(
"Invalid argument passed to marshall(DescribeEndpointsRequest)");
}
Request<DescribeEndpointsRequest> request = new DefaultRequest<DescribeEndpointsRequest>(
describeEndpointsRequest, "AmazonDynamoDB");
String target = "DynamoDB_20120810.DescribeEndpoints";
request.addHeader("X-Amz-Target", target);
request.setHttpMethod(HttpMethodName.POST);
String uriResourcePath = "/";
request.setResourcePath(uriResourcePath);
request.addHeader("Content-Length", "0");
request.setContent(new ByteArrayInputStream(new byte[0]));
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/x-amz-json-1.0");
}
return request;
}
}
代码示例来源:origin: aws/aws-sdk-java
request.setResourcePath(uriResourcePath);
StringWriter stringWriter = new StringWriter();
XMLWriter xmlWriter = new XMLWriter(stringWriter, "http://cloudfront.amazonaws.com/doc/2018-11-05/");
xmlWriter.startElement("CallerReference").value(cloudFrontOriginAccessIdentityConfig.getCallerReference()).endElement();
xmlWriter.startElement("Comment").value(cloudFrontOriginAccessIdentityConfig.getComment()).endElement();
request.setContent(new StringInputStream(stringWriter.getBuffer().toString()));
request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length));
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/xml");
代码示例来源:origin: aws-amplify/aws-sdk-android
public Request<DescribeLimitsRequest> marshall(DescribeLimitsRequest describeLimitsRequest) {
if (describeLimitsRequest == null) {
throw new AmazonClientException(
"Invalid argument passed to marshall(DescribeLimitsRequest)");
}
Request<DescribeLimitsRequest> request = new DefaultRequest<DescribeLimitsRequest>(
describeLimitsRequest, "AmazonKinesis");
String target = "Kinesis_20131202.DescribeLimits";
request.addHeader("X-Amz-Target", target);
request.setHttpMethod(HttpMethodName.POST);
String uriResourcePath = "/";
request.setResourcePath(uriResourcePath);
request.addHeader("Content-Length", "0");
request.setContent(new ByteArrayInputStream(new byte[0]));
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/x-amz-json-1.1");
}
return request;
}
}
代码示例来源:origin: aws/aws-sdk-java
request.setResourcePath(uriResourcePath);
StringWriter stringWriter = new StringWriter();
XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/");
xmlWriter.startElement("Document").value(createTrafficPolicyVersionRequest.getDocument()).endElement();
xmlWriter.startElement("Comment").value(createTrafficPolicyVersionRequest.getComment()).endElement();
request.setContent(new StringInputStream(stringWriter.getBuffer().toString()));
request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length));
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/xml");
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
@Override
public Request<OrigRequest> finishMarshalling() {
// Content may already be set if the payload is binary data.
if (request.getContent() == null) {
// End the implicit request object if needed.
if (!hasExplicitPayloadMember) {
jsonGenerator.writeEndObject();
}
byte[] content = jsonGenerator.getBytes();
request.setContent(new ByteArrayInputStream(content));
if (content.length > 0) {
request.addHeader("Content-Length", Integer.toString(content.length));
}
}
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", contentType);
}
return request;
}
代码示例来源:origin: aws/aws-sdk-java
request.setResourcePath(uriResourcePath);
StringWriter stringWriter = new StringWriter();
XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/");
xmlWriter.value(listTagsForResourcesRequestResourceIdsListValue);
xmlWriter.endElement();
request.setContent(new StringInputStream(stringWriter.getBuffer().toString()));
request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length));
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/xml");
代码示例来源:origin: aws-amplify/aws-sdk-android
public Request<ClearDefaultAuthorizerRequest> marshall(
ClearDefaultAuthorizerRequest clearDefaultAuthorizerRequest) {
if (clearDefaultAuthorizerRequest == null) {
throw new AmazonClientException(
"Invalid argument passed to marshall(ClearDefaultAuthorizerRequest)");
}
Request<ClearDefaultAuthorizerRequest> request = new DefaultRequest<ClearDefaultAuthorizerRequest>(
clearDefaultAuthorizerRequest, "AWSIot");
request.setHttpMethod(HttpMethodName.DELETE);
String uriResourcePath = "/default-authorizer";
request.setResourcePath(uriResourcePath);
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/x-amz-json-1.0");
}
return request;
}
}
代码示例来源:origin: aws/aws-sdk-java
request.setResourcePath(uriResourcePath);
StringWriter stringWriter = new StringWriter();
XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/");
xmlWriter.startElement("Name").value(createTrafficPolicyRequest.getName()).endElement();
xmlWriter.startElement("Document").value(createTrafficPolicyRequest.getDocument()).endElement();
xmlWriter.startElement("Comment").value(createTrafficPolicyRequest.getComment()).endElement();
request.setContent(new StringInputStream(stringWriter.getBuffer().toString()));
request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length));
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/xml");
内容来源于网络,如有侵权,请联系作者删除!