utils

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2016 License: MIT, MIT Imports: 6 Imported by: 0

README

gentleman/utils Build Status GoDoc API Go Report Card

utils package provides a few HTTP specific utilities internally used by gentleman.

Installation

go get -u gopkg.in/h2non/gentleman.v0/utils

API

See godoc reference.

License

MIT - Tomas Aparicio

Documentation

Overview

Package utils provides a set of reusable HTTP client utilities used internally in gentleman for required functionality and testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureTransporterFinalized

func EnsureTransporterFinalized(httpTransport *http.Transport)

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

func ReplyWithStatus(res *http.Response, code int)

ReplyWithStatus helper to write the http.Response status code and text.

func SetTransportFinalizer

func SetTransportFinalizer(transport *http.Transport)

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

func WriteBodyString(res *http.Response, body string)

WriteBodyString writes a string based body in a given http.Response.

Types

type XMLCharDecoder

type XMLCharDecoder func(charset string, input io.Reader) (io.Reader, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL