# Packages
Package r2test provides helpers for writing tests involving calls with sdk/r2.
# Functions
EnsureHTTPTransport ensures the http client's transport is set and that it is an *http.Transport.
ErrIsTooManyRedirects returns if the error is too many redirects.
GetParameterizedPath gets a path with named parameters off a context.
GetRawURLParameterized gets a URL string with named route parameters in place of the raw path for a request.
GetServiceHostName gets a service hostName off a context.
New returns a new request.
NewEvent returns a new event.
NewEventFilter returns a new r2 event filter.
NewEventListener returns a new r2 event listener.
OptBasicAuth is an option that sets the http basic auth.
OptBody sets the post body on the request.
OptBodyBytes sets the post body on the request from a byte array.
OptClient sets the underlying client on the request.
OptCloser sets the request closer.
OptContext sets the request context.
OptCookie adds a cookie.
OptCookieValue adds a cookie with a given name and value.
OptDelete sets the request method.
OptDial sets dial options for a request, these must be done all at once.
OptDialKeepAlive sets the dial keep alive duration.
OptDialTimeout sets the dial timeout.
OptDisableKeepAlives disables keep alives.
OptEventBody sets the body.
OptEventElapsed sets the elapsed time.
OptEventRequest sets the response.
OptEventResponse sets the response.
OptGet sets the request method.
OptHeader sets the request headers.
OptHeaderValue adds or sets a header value.
OptHost sets the url host.
OptHTTPClientTrace sets the outgoing httptrace.ClientTrace context.
OptJSONBody sets the post body on the request.
OptLog adds OnRequest and OnResponse listeners to log that a call was made.
OptLogRequest adds OnRequest and OnResponse listeners to log that a call was made.
OptLogResponse adds an OnResponse listener to log the response of a call.
OptLogResponseWithBody adds an OnResponse listener to log the response of a call.
OptLogWithBody adds OnRequest and OnResponse listeners to log that a call was made.
OptMaxRedirects tells the http client to only follow a given number of redirects, overriding the standard library default of 10.
OptMethod sets the request method.
OptNoFollow tells the http client to not follow redirects returned by the remote server.
OptOnRequest sets an on request listener.
OptOnResponse adds an on response listener.
OptPatch sets the request method.
OptPath sets the url path.
OptPathf sets the url path based on a format and arguments.
OptPathParameterized sets the url path based on a parameterized path and arguments.
OptPort sets a custom port for the request url.
OptPost sets the request method.
OptPostedFiles adds multipart uploads to the request.
OptPostForm sets the request post form and the content type.
OptPostFormValue sets a request post form value.
OptPut sets the request method.
OptQuery sets the full querystring.
OptQueryValue sets a query value.
OptQueryValueAdd adds a query value.
OptResponseHeaderTimeout sets the client transport ResponseHeaderTimeout.
OptScheme sets the url scheme.
OptServiceHostName sets the service hostName within an outgoing request context.
OptTimeout sets the client timeout.
OptTLSClientCert adds a client cert and key to the request.
OptTLSClientCertFilePair adds a client cert and key to the request.
OptTLSClientCertObject adds a client cert to the request.
OptTLSClientConfig sets the tls config for the request.
OptTLSHandshakeTimeout sets the client transport TLSHandshakeTimeout.
OptTLSRootCAs sets the client tls root ca pool.
OptTLSSkipVerify sets if we should skip verification.
OptTracer sets the optional trace handler.
OptTransport sets the client transport for a request.
OptURL sets the url of a request.
OptUserAgent sets the user agent header on a request.
OptXMLBody sets the post body on the request.
RequestOption translates a webutil.RequestOption to a r2.Option.
WithParameterizedPath adds a path with named parameters to a context.
WithServiceHostName adds a service hostName to a context.
# Constants
ConnectionKeepAlive is a connection header value.
ContentTypeApplicationFormEncoded is a content type header value.
ContentTypeApplicationJSON is a content type header value.
ContentTypeApplicationOctetStream is a content type header value.
ContentTypeApplicationXML is a content type header value.
ErrInvalidMethod is an error that is returned from `r2.Request.Do()` if a method is specified on the request that violates the valid charset for HTTP methods.
ErrInvalidTransport is an error returned from options if they are called on a request that has had the transport set to something other than an *http.Transport; this precludes using http.Transport specific options like tls.Config mutators.
ErrMismatchedPathParameters is an error that is returned from `OptPathParameterized()` if the parameterized path string has a different number of parameters than what was passed as variadic arguments.
ErrNoContentJSON is returns from sending requests when a no-content status is returned.
ErrNoContentXML is returns from sending requests when a no-content status is returned.
ErrRequestUnset is an error returned from options if they are called on a r2.Request that has not been created by r2.New(), and as a result the underlying request is uninitialized.
Flag is a logger event flag.
FlagResponse is a logger event flag.
MethodDelete is a method.
MethodGet is a method.
MethodOptions is a method.
MethodPatch is a method.
MethodPost is a method.
MethodPut is a method.
TestURL can be used in tests for the URL passed to r2.New(...)
The URL itself sets `https` as the scheme, `test.invalid` as the host, `/test` as the path, and `query=value` as the querystring.
# Variables
HeaderConnection is a http header.
HeaderContentType is a http header.
# Structs
Event is a response to outgoing requests.
EventJSONSchema is the json schema of the logger event.
LogOptions are options that govern the logging of requests.
Request is a combination of the http.Request options and the underlying client.
# Type aliases
DialOption is an option for the net dialer.
EventOption is an event option.
LogOption are mutators for log options.
OnRequestListener is an a listener for on request events.
OnResponseListener is an on response listener.
Option is a modifier for a request.