Documentation ¶
Overview ¶
Package utils provides a set of reusable HTTP client utilities used internally in gentleman for required functionality and testing.
Index ¶
- func EnsureTransporterFinalized(httpTransport *http.Transport)
- func NopCloser() io.ReadCloser
- func ReplyWithStatus(res *http.Response, code int)
- func SetTransportFinalizer(transport *http.Transport)
- func StringReader(body string) io.ReadCloser
- func WriteBodyString(res *http.Response, body string)
- type XMLCharDecoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureTransporterFinalized ¶
EnsureTransporterFinalized will ensure that when the HTTP client is GCed the runtime will close the idle connections (so that they won't leak) this function was adopted from Hashicorp's go-cleanhttp package.
func NopCloser ¶
func NopCloser() io.ReadCloser
NopCloser returns a ReadCloser with a no-op Close
method wrapping the provided Reader r.
func ReplyWithStatus ¶
ReplyWithStatus helper to write the http.Response status code and text.
func SetTransportFinalizer ¶
SetTransportFinalizer sets a finalizer on the transport to ensure that idle connections are closed prior to garbage collection; otherwise these may leak.
func StringReader ¶
func StringReader(body string) io.ReadCloser
StringReader creates an io.ReadCloser interface from a string.
func WriteBodyString ¶
WriteBodyString writes a string based body in a given http.Response.
Types ¶
type XMLCharDecoder ¶
XMLCharDecoder is a helper type that takes a stream of bytes (not encoded in UTF-8) and returns a reader that encodes the bytes into UTF-8. This is done because Go's XML library only supports XML encoded in UTF-8.