package httputilx
import "github.com/teamwork/utils/httputilx"
Package httputilx provides HTTP utility functions.
Index ¶
- func DumpBody(r *http.Request, maxSize int64) ([]byte, error)
- func Fetch(url string) ([]byte, error)
- func Save(url string, dir string, filename string) (string, error)
- type ErrNotOK
Functions ¶
func DumpBody ¶
DumpBody reads the body of a HTTP request without consuming it, so it can be read again later. It will read at most maxSize of bytes. Use -1 to read everything.
It's based on httputil.DumpRequest.
Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file: https://golang.org/LICENSE
func Fetch ¶
Fetch the contents of an HTTP URL.
This is not intended to cover all possible use cases for fetching files, only the most common ones. Use the net/http package for more advanced usage.
func Save ¶
Save an HTTP URL to the directory dir with the filename. The filename can be generated from the URL if empty.
It will return the full path to the save file. Note that it may create both a file *and* return an error (e.g. in cases of non-200 status codes).
This is not intended to cover all possible use cases for fetching files, only the most common ones. Use the net/http package for more advanced usage.
Types ¶
type ErrNotOK ¶
ErrNotOK is used when the status code is not 200 OK.
func (ErrNotOK) Error ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
httputilx/header | Package header provides functions for parsing and setting HTTP headers. |
- Version
- v1.0.0 (latest)
- Published
- Mar 14, 2022
- Platform
- windows/amd64
- Imports
- 12 packages
- Last checked
- 1 hour ago –
Tools for package owners.