Package: corehandlers

import "../ibm-cos-sdk-go/aws/corehandlers"

Variables

var BuildContentLengthHandler = writable

BuildContentLengthHandler builds the content length of a request based on the body, or will use the HTTPRequest.Header's “Content-Length” if defined. If unable to determine request body length and no “Content-Length” was specified it will panic.

The Content-Length will only be added to the request if the length of the body is greater than 0. If the body is empty or the current Content-Length header is <= 0, the header will also be stripped.

Value:

request.NamedHandler{Name: "core.BuildContentLengthHandler", Fn: func(r *request.Request) { var length int64 if slength := r.HTTPRequest.Header.Get("Content-Length"); slength != "" { length, _ = strconv.ParseInt(slength, 10, 64) } else { if r.Body != nil { var err error length, err = aws.SeekerLen(r.Body) if err != nil { r.Error = awserr.New(request.ErrCodeSerialization, "failed to get request body's length", err) return } } } if length > 0 { r.HTTPRequest.ContentLength = length r.HTTPRequest.Header.Set("Content-Length", fmt.Sprintf("%d", length)) } else { r.HTTPRequest.ContentLength = 0 r.HTTPRequest.Header.Del("Content-Length") } }}
var ValidateReqSigHandler = writable

ValidateReqSigHandler is a request handler to ensure that the request's signature doesn't expire before it is sent. This can happen when a request is built and signed significantly before it is sent. Or significant delays occur when retrying requests that would cause the signature to expire.

Value:

request.NamedHandler{ Name: "core.ValidateReqSigHandler", Fn: func(r *request.Request) { // Unsigned requests are not signed if r.Config.Credentials == credentials.AnonymousCredentials { return } signedTime := r.Time if !r.LastSignedAt.IsZero() { signedTime = r.LastSignedAt } // 5 minutes to allow for some clock skew/delays in transmission. // Would be improved with aws/aws-sdk-go#423 if signedTime.Add(5 * time.Minute).After(time.Now()) { return } fmt.Println("request expired, resigning") r.Sign() }, }
var SendHandler = writable

SendHandler is a request handler to send service request using HTTP client.

Value:

request.NamedHandler{ Name: "core.SendHandler", Fn: func(r *request.Request) { sender := sendFollowRedirects if r.DisableFollowRedirects { sender = sendWithoutFollowRedirects } if request.NoBody == r.HTTPRequest.Body { // Strip off the request body if the NoBody reader was used as a // place holder for a request body. This prevents the SDK from // making requests with a request body when it would be invalid // to do so. // // Use a shallow copy of the http.Request to ensure the race condition // of transport on Body will not trigger reqOrig, reqCopy := r.HTTPRequest, *r.HTTPRequest reqCopy.Body = nil r.HTTPRequest = &reqCopy defer func() { r.HTTPRequest = reqOrig }() } var err error r.HTTPResponse, err = sender(r) if err != nil { handleSendError(r, err) } }, }
var ValidateResponseHandler = writable

ValidateResponseHandler is a request handler to validate service response.

Value:

request.NamedHandler{Name: "core.ValidateResponseHandler", Fn: func(r *request.Request) { if r.HTTPResponse.StatusCode == 0 || r.HTTPResponse.StatusCode >= 300 { // this may be replaced by an UnmarshalError handler r.Error = awserr.New("UnknownError", "unknown error", r.Error) } }}
var AfterRetryHandler = writable

AfterRetryHandler performs final checks to determine if the request should be retried and how long to delay.

Value:

request.NamedHandler{ Name: "core.AfterRetryHandler", Fn: func(r *request.Request) { // If one of the other handlers already set the retry state // we don't want to override it based on the service's state if r.Retryable == nil || aws.BoolValue(r.Config.EnforceShouldRetryCheck) { r.Retryable = aws.Bool(r.ShouldRetry(r)) } if r.WillRetry() { r.RetryDelay = r.RetryRules(r) if sleepFn := r.Config.SleepDelay; sleepFn != nil { // Support SleepDelay for backwards compatibility and testing sleepFn(r.RetryDelay) } else if err := aws.SleepWithContext(r.Context(), r.RetryDelay); err != nil { r.Error = awserr.New(request.CanceledErrorCode, "request context canceled", err) r.Retryable = aws.Bool(false) return } // when the expired token exception occurs the credentials // need to be expired locally so that the next request to // get credentials will trigger a credentials refresh. if r.IsErrorExpired() { r.Config.Credentials.Expire() } r.RetryCount++ r.Error = nil } }}
var ValidateEndpointHandler = writable

ValidateEndpointHandler is a request handler to validate a request had the appropriate Region and Endpoint set. Will set r.Error if the endpoint or region is not valid.

Value:

request.NamedHandler{Name: "core.ValidateEndpointHandler", Fn: func(r *request.Request) { // IBM COS SDK Code -- START checkIfRegionPresent := true // Anonymous Creds support if r.Config.Credentials != credentials.AnonymousCredentials { value, err := r.Config.Credentials.Get() if err != nil { r.Error = err return } checkIfRegionPresent = value.ProviderType == "" || value.ProviderType == "v4" } if checkIfRegionPresent && r.ClientInfo.SigningRegion == "" && aws.StringValue(r.Config.Region) == "" { r.Error = aws.ErrMissingRegion } else if r.ClientInfo.Endpoint == "" { // Was any endpoint provided by the user, or one was derived by the // SDK's endpoint resolver? r.Error = aws.ErrMissingEndpoint } // IBM COS SDK Code -- END }}
var SDKVersionUserAgentHandler = writable

SDKVersionUserAgentHandler is a request handler for adding the SDK Version to the user agent.

Value:

request.NamedHandler{ Name: "core.SDKVersionUserAgentHandler", Fn: request.MakeAddToUserAgentHandler(aws.SDKName, aws.SDKVersion, runtime.Version(), runtime.GOOS, runtime.GOARCH), }
var AddHostExecEnvUserAgentHander = writable

AddHostExecEnvUserAgentHander is a request handler appending the SDK's execution environment to the user agent.

If the environment variable AWS_EXECUTION_ENV is set, its value will be appended to the user agent string.

Value:

request.NamedHandler{ Name: "core.AddHostExecEnvUserAgentHander", Fn: func(r *request.Request) { v := os.Getenv(execEnvVar) if len(v) == 0 { return } request.AddToUserAgent(r, execEnvUAKey+"/"+v) }, }
var ValidateParametersHandler = writable

ValidateParametersHandler is a request handler to validate the input parameters. Validating parameters only has meaning if done prior to the request being sent.

Value:

request.NamedHandler{Name: "core.ValidateParametersHandler", Fn: func(r *request.Request) { if !r.ParamsFilled() { return } if v, ok := r.Params.(request.Validator); ok { if err := v.Validate(); err != nil { r.Error = err } } }}