Documentation ¶
Overview ¶
Network related utilities
Index ¶
- Constants
- func CopyHeaders(dst, src http.Header)
- func CopyUrl(in *url.URL) *url.URL
- func HasHeaders(names []string, headers http.Header) bool
- func MustParseUrl(inUrl string) *url.URL
- func NewHttpResponse(request *http.Request, statusCode int, body []byte, contentType string) *http.Response
- func NewJsonResponse(request *http.Request, statusCode int, message interface{}) *http.Response
- func NewMultiReaderSeeker(length int64, cleanup CleanupFunc, readers ...io.ReadSeeker) *multiReaderSeek
- func NewTextResponse(request *http.Request, statusCode int, body string) *http.Response
- func ParseUrl(inUrl string) (*url.URL, error)
- func RemoveHeaders(names []string, headers http.Header)
- type BasicAuth
- type BodyBufferOptions
- type CleanupFunc
- type MaxReader
- type MaxSizeReachedError
- type MultiReader
Constants ¶
View Source
const ( DefaultMemBufferBytes = 1048576 DefaultMaxSizeBytes = -1 )
Variables ¶
This section is empty.
Functions ¶
func CopyHeaders ¶
Copies http headers from source to destination does not overide, but adds multiple headers
func CopyUrl ¶
Provides update safe copy by avoiding shallow copying certain fields (like user data)
func HasHeaders ¶
Determines whether any of the header names is present in the http headers
func MustParseUrl ¶
func NewHttpResponse ¶
func NewJsonResponse ¶
func NewMultiReaderSeeker ¶
func NewMultiReaderSeeker(length int64, cleanup CleanupFunc, readers ...io.ReadSeeker) *multiReaderSeek
func NewTextResponse ¶
func ParseUrl ¶
Standard parse url is very generous, parseUrl wrapper makes it more strict and demands scheme and host to be set
func RemoveHeaders ¶
Removes the header with the given names from the headers map
Types ¶
type BasicAuth ¶
func ParseAuthHeader ¶
type BodyBufferOptions ¶
type BodyBufferOptions struct { // MemBufferBytes sets up the size of the memory buffer for this request. // If the data size exceeds the limit, the remaining request part will be saved on the file system. MemBufferBytes int64 // Max size bytes, ignored if set to value <= 0, if request exceeds the specified limit, the reader will fail. MaxSizeBytes int64 }
type CleanupFunc ¶
type CleanupFunc func() error
type MaxReader ¶
type MaxReader struct { R io.Reader // underlying reader N int64 // bytes read Max int64 // max bytes to read }
MaxReader does not allow to read more than Max bytes and returns error if this limit has been exceeded.
type MaxSizeReachedError ¶
type MaxSizeReachedError struct {
MaxSize int64
}
func (*MaxSizeReachedError) Error ¶
func (e *MaxSizeReachedError) Error() string
type MultiReader ¶
type MultiReader interface { io.Reader io.Seeker io.Closer // TotalSize calculates and returns the total size of the reader and not the length remaining. TotalSize() (int64, error) }
MultiReader provides Read, Close and Seek and TotalSize methods.
func NewBodyBuffer ¶
func NewBodyBuffer(input io.Reader) (MultiReader, error)
func NewBodyBufferWithOptions ¶
func NewBodyBufferWithOptions(input io.Reader, o BodyBufferOptions) (MultiReader, error)
Click to show internal directories.
Click to hide internal directories.