createOriginRequestPolicy2020_05_31 method
- required OriginRequestPolicyConfig originRequestPolicyConfig,
Creates an origin request policy.
After you create an origin request policy, you can attach it to one or more cache behaviors. When it’s attached to a cache behavior, the origin request policy determines the values that CloudFront includes in requests that it sends to the origin. Each request that CloudFront sends to the origin includes the following:
- The request body and the URL path (without the domain name) from the viewer request.
-
The headers that CloudFront automatically includes in every origin
request, including
Host
,User-Agent
, andX-Amz-Cf-Id
. - All HTTP headers, cookies, and URL query strings that are specified in the cache policy or the origin request policy. These can include items from the viewer request and, in the case of headers, additional ones that are added by CloudFront.
CachePolicy
.
For more information about origin request policies, see Controlling origin requests in the Amazon CloudFront Developer Guide.
May throw AccessDenied. May throw InconsistentQuantities. May throw InvalidArgument. May throw OriginRequestPolicyAlreadyExists. May throw TooManyOriginRequestPolicies. May throw TooManyHeadersInOriginRequestPolicy. May throw TooManyCookiesInOriginRequestPolicy. May throw TooManyQueryStringsInOriginRequestPolicy.
Parameter originRequestPolicyConfig
:
An origin request policy configuration.
Implementation
Future<CreateOriginRequestPolicyResult> createOriginRequestPolicy2020_05_31({
required OriginRequestPolicyConfig originRequestPolicyConfig,
}) async {
ArgumentError.checkNotNull(
originRequestPolicyConfig, 'originRequestPolicyConfig');
final $result = await _protocol.sendRaw(
method: 'POST',
requestUri: '/2020-05-31/origin-request-policy',
payload: originRequestPolicyConfig.toXml('OriginRequestPolicyConfig'),
exceptionFnMap: _exceptionFns,
);
final $elem = await _s.xmlFromResponse($result);
return CreateOriginRequestPolicyResult(
originRequestPolicy: OriginRequestPolicy.fromXml($elem),
eTag: _s.extractHeaderStringValue($result.headers, 'ETag'),
location: _s.extractHeaderStringValue($result.headers, 'Location'),
);
}