Documentation

Overview

    Package http provides the HTTP transport client and request/response types needed to round trip API operation calls with an service.

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func AddCloseResponseBodyMiddleware

    func AddCloseResponseBodyMiddleware(stack *middleware.Stack) error

      AddCloseResponseBodyMiddleware adds the middleware to automatically close the response body of an operation request, after the response had been deserialized.

      func AddComputeContentLengthMiddleware

      func AddComputeContentLengthMiddleware(stack *middleware.Stack) error

        AddComputeContentLengthMiddleware adds ComputeContentLength to the middleware stack's Build step.

        func AddContentChecksumMiddleware

        func AddContentChecksumMiddleware(stack *middleware.Stack) error

          AddContentChecksumMiddleware adds checksum middleware to middleware's build step.

          func AddErrorCloseResponseBodyMiddleware

          func AddErrorCloseResponseBodyMiddleware(stack *middleware.Stack) error

            AddErrorCloseResponseBodyMiddleware adds the middleware to automatically close the response body of an operation request if the request response failed.

            func AddHeaderValue

            func AddHeaderValue(header string, value string) func(stack *middleware.Stack) error

              AddHeaderValue returns a stack mutator that adds the header value pair to header. Appends to any existing values if present.

              func DisableEndpointHostPrefix

              func DisableEndpointHostPrefix(ctx context.Context, value bool) context.Context

                DisableEndpointHostPrefix sets or modifies if the request's endpoint host prefixing to be disabled. If value is set to true, endpoint host prefixing will be disabled.

                Scoped to stack values. Use middleware#ClearStackValues to clear all stack values.

                func GetHostnameImmutable

                func GetHostnameImmutable(ctx context.Context) (v bool)

                  GetHostnameImmutable retrieves if the endpoint hostname should be considered immutable or not.

                  Scoped to stack values. Use middleware#ClearStackValues to clear all stack values.

                  func IsEndpointHostPrefixDisabled

                  func IsEndpointHostPrefixDisabled(ctx context.Context) (v bool)

                    IsEndpointHostPrefixDisabled retrieves if the hostname prefixing is disabled.

                    Scoped to stack values. Use middleware#ClearStackValues to clear all stack values.

                    func JoinPath

                    func JoinPath(a, b string) string

                      JoinPath returns an absolute URL path composed of the two paths provided. Enforces that the returned path begins with '/'. If added path is empty the returned path suffix will match the first parameter suffix.

                      func JoinRawQuery

                      func JoinRawQuery(a, b string) string

                        JoinRawQuery returns an absolute raw query expression. Any duplicate '&' will be collapsed to single separator between values.

                        func NewStackRequest

                        func NewStackRequest() interface{}

                          NewStackRequest returns an initialized request ready to populated with the HTTP request details. Returns empty interface so the function can be used as a parameter to the Smithy middleware Stack constructor.

                          func ParseTime

                          func ParseTime(text string) (t time.Time, err error)

                            ParseTime parses a time header like the HTTP Date header. This uses a more relaxed rule set for date parsing compared to the standard library.

                            func RequestCloner

                            func RequestCloner(v interface{}) interface{}

                              RequestCloner is a function that can take an input request type and clone the request for use in a subsequent retry attempt

                              func SetHeaderValue

                              func SetHeaderValue(header string, value string) func(stack *middleware.Stack) error

                                SetHeaderValue returns a stack mutator that adds the header value pair to header. Replaces any existing values if present.

                                func SetHostnameImmutable

                                func SetHostnameImmutable(ctx context.Context, value bool) context.Context

                                  SetHostnameImmutable sets or modifies if the request's endpoint hostname should be considered immutable or not.

                                  Scoped to stack values. Use middleware#ClearStackValues to clear all stack values.

                                  func SplitHTTPDateTimestampHeaderListValues

                                  func SplitHTTPDateTimestampHeaderListValues(vs []string) ([]string, error)

                                    SplitHTTPDateTimestampHeaderListValues attempts to split the HTTP-Date timestamp values in the slice by commas, and return a list of all values separated. The split is aware of HTTP-Date timestamp format, and will skip comma within the timestamp value. Returns an error if unable to split the timestamp values.

                                    func SplitHeaderListValues

                                    func SplitHeaderListValues(vs []string) ([]string, error)

                                      SplitHeaderListValues attempts to split the elements of the slice by commas, and return a list of all values separated. Returns error if unable to separate the values.

                                      func ValidHostLabel

                                      func ValidHostLabel(label string) bool

                                        ValidHostLabel returns if the label is a valid RFC 3986 host label.

                                        func ValidPortNumber

                                        func ValidPortNumber(port string) bool

                                          ValidPortNumber return if the port is valid RFC 3986 port

                                          func ValidateContentLengthHeader

                                          func ValidateContentLengthHeader(stack *middleware.Stack) error

                                            ValidateContentLengthHeader adds middleware that validates request content-length is set to value greater than zero.

                                            func ValidateEndpointHost

                                            func ValidateEndpointHost(host string) error

                                              ValidateEndpointHost validates that the host string passed in is a valid RFC 3986 host. Returns error if the host is not valid.

                                              Types

                                              type ClientDo

                                              type ClientDo interface {
                                              	Do(*http.Request) (*http.Response, error)
                                              }

                                                ClientDo provides the interface for custom HTTP client implementations.

                                                type ClientDoFunc

                                                type ClientDoFunc func(*http.Request) (*http.Response, error)

                                                  ClientDoFunc provides a helper to wrap an function as an HTTP client for round tripping requests.

                                                  func (ClientDoFunc) Do

                                                  func (fn ClientDoFunc) Do(r *http.Request) (*http.Response, error)

                                                    Do will invoke the underlying func, returning the result.

                                                    type ClientHandler

                                                    type ClientHandler struct {
                                                    	// contains filtered or unexported fields
                                                    }

                                                      ClientHandler wraps a client that implements the HTTP Do method. Standard implementation is http.Client.

                                                      func NewClientHandler

                                                      func NewClientHandler(client ClientDo) ClientHandler

                                                        NewClientHandler returns an initialized middleware handler for the client.

                                                        func (ClientHandler) Handle

                                                        func (c ClientHandler) Handle(ctx context.Context, input interface{}) (
                                                        	out interface{}, metadata middleware.Metadata, err error,
                                                        )

                                                          Handle implements the middleware Handler interface, that will invoke the underlying HTTP client. Requires the input to be an Smithy *Request. Returns a smithy *Response, or error if the request failed.

                                                          type ComputeContentLength

                                                          type ComputeContentLength struct {
                                                          }

                                                            ComputeContentLength provides a middleware to set the content-length header for the length of a serialize request body.

                                                            func (*ComputeContentLength) HandleBuild

                                                              HandleBuild adds the length of the serialized request to the HTTP header if the length can be determined.

                                                              func (*ComputeContentLength) ID

                                                              func (m *ComputeContentLength) ID() string

                                                                ID the identifier for the ComputeContentLength

                                                                type NopClient

                                                                type NopClient struct{}

                                                                  NopClient provides a client that ignores the request, and returns a empty successful HTTP response value.

                                                                  func (NopClient) Do

                                                                  func (NopClient) Do(r *http.Request) (*http.Response, error)

                                                                    Do ignores the request and returns a 200 status empty response.

                                                                    type Request

                                                                    type Request struct {
                                                                    	*http.Request
                                                                    	// contains filtered or unexported fields
                                                                    }

                                                                      Request provides the HTTP specific request structure for HTTP specific middleware steps to use to serialize input, and send an operation's request.

                                                                      Example (SerializeMiddleware)
                                                                      Output:
                                                                      
                                                                      foo-name abc
                                                                      bar-count 123
                                                                      

                                                                      func (*Request) Build

                                                                      func (r *Request) Build(ctx context.Context) *http.Request

                                                                        Build returns a build standard HTTP request value from the Smithy request. The request's stream is wrapped in a safe container that allows it to be reused for subsequent attempts.

                                                                        func (*Request) Clone

                                                                        func (r *Request) Clone() *Request

                                                                          Clone returns a deep copy of the Request for the new context. A reference to the Stream is copied, but the underlying stream is not copied.

                                                                          func (*Request) GetStream

                                                                          func (r *Request) GetStream() io.Reader

                                                                            GetStream returns the request stream io.Reader if a stream is set. If no stream is present nil will be returned.

                                                                            func (*Request) IsStreamSeekable

                                                                            func (r *Request) IsStreamSeekable() bool

                                                                              IsStreamSeekable returns if the stream is seekable.

                                                                              func (*Request) RewindStream

                                                                              func (r *Request) RewindStream() error

                                                                                RewindStream will rewind the io.Reader to the relative start position if it is an io.Seeker.

                                                                                func (*Request) SetStream

                                                                                func (r *Request) SetStream(reader io.Reader) (rc *Request, err error)

                                                                                  SetStream returns a clone of the request with the stream set to the provided reader. May return an error if the provided reader is seekable but returns an error.

                                                                                  func (*Request) StreamLength

                                                                                  func (r *Request) StreamLength() (size int64, ok bool, err error)

                                                                                    StreamLength returns the number of bytes of the serialized stream attached to the request and ok set. If the length cannot be determined, an error will be returned.

                                                                                    type RequestResponseLogger

                                                                                    type RequestResponseLogger struct {
                                                                                    	LogRequest         bool
                                                                                    	LogRequestWithBody bool
                                                                                    
                                                                                    	LogResponse         bool
                                                                                    	LogResponseWithBody bool
                                                                                    }

                                                                                      RequestResponseLogger is a deserialize middleware that will log the request and response HTTP messages and optionally their respective bodies. Will not perform any logging if none of the options are set.

                                                                                      func (*RequestResponseLogger) HandleDeserialize

                                                                                        HandleDeserialize will log the request and response HTTP messages if configured accordingly.

                                                                                        func (*RequestResponseLogger) ID

                                                                                        func (r *RequestResponseLogger) ID() string

                                                                                          ID is the middleware identifier.

                                                                                          type RequestSendError

                                                                                          type RequestSendError struct {
                                                                                          	Err error
                                                                                          }

                                                                                            RequestSendError provides a generic request transport error. This error should wrap errors making HTTP client requests.

                                                                                            The ClientHandler will wrap the HTTP client's error if the client request fails, and did not fail because of context canceled.

                                                                                            func (*RequestSendError) ConnectionError

                                                                                            func (e *RequestSendError) ConnectionError() bool

                                                                                              ConnectionError return that the error is related to not being able to send the request, or receive a response from the service.

                                                                                              func (*RequestSendError) Error

                                                                                              func (e *RequestSendError) Error() string

                                                                                              func (*RequestSendError) Unwrap

                                                                                              func (e *RequestSendError) Unwrap() error

                                                                                                Unwrap returns the underlying error, if there was one.

                                                                                                type Response

                                                                                                type Response struct {
                                                                                                	*http.Response
                                                                                                }

                                                                                                  Response provides the HTTP specific response structure for HTTP specific middleware steps to use to deserialize the response from an operation call.

                                                                                                  Example (DeserializeMiddleware)
                                                                                                  Output:
                                                                                                  
                                                                                                  FooName abc
                                                                                                  BarCount 123
                                                                                                  Metadata: example-meta: meta-value
                                                                                                  

                                                                                                  type ResponseError

                                                                                                  type ResponseError struct {
                                                                                                  	Response *Response
                                                                                                  	Err      error
                                                                                                  }

                                                                                                    ResponseError provides the HTTP centric error type wrapping the underlying error with the HTTP response value.

                                                                                                    Example
                                                                                                    Output:
                                                                                                    
                                                                                                    request failed: FooException, some message about the error
                                                                                                    response status: 404
                                                                                                    response header: foo value
                                                                                                    

                                                                                                    func (*ResponseError) Error

                                                                                                    func (e *ResponseError) Error() string

                                                                                                    func (*ResponseError) HTTPResponse

                                                                                                    func (e *ResponseError) HTTPResponse() *Response

                                                                                                      HTTPResponse returns the HTTP response received from the service.

                                                                                                      func (*ResponseError) HTTPStatusCode

                                                                                                      func (e *ResponseError) HTTPStatusCode() int

                                                                                                        HttpStatusCode returns the HTTP response status code received from the service

                                                                                                        func (*ResponseError) Unwrap

                                                                                                        func (e *ResponseError) Unwrap() error

                                                                                                          Unwrap returns the nested error if any, or nil.

                                                                                                          type UserAgentBuilder

                                                                                                          type UserAgentBuilder struct {
                                                                                                          	// contains filtered or unexported fields
                                                                                                          }

                                                                                                            UserAgentBuilder is a builder for a HTTP User-Agent string.

                                                                                                            func NewUserAgentBuilder

                                                                                                            func NewUserAgentBuilder() *UserAgentBuilder

                                                                                                              NewUserAgentBuilder returns a new UserAgentBuilder.

                                                                                                              func (*UserAgentBuilder) AddKey

                                                                                                              func (u *UserAgentBuilder) AddKey(key string)

                                                                                                                AddKey adds the named component/product to the agent string

                                                                                                                func (*UserAgentBuilder) AddKeyValue

                                                                                                                func (u *UserAgentBuilder) AddKeyValue(key, value string)

                                                                                                                  AddKeyValue adds the named key to the agent string with the given value.

                                                                                                                  func (*UserAgentBuilder) Build

                                                                                                                  func (u *UserAgentBuilder) Build() string

                                                                                                                    Build returns the constructed User-Agent string. May be called multiple times.

                                                                                                                    Directories

                                                                                                                    Path Synopsis
                                                                                                                    internal
                                                                                                                    io