httputilx

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package httputilx provides HTTP utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpBody

func DumpBody(r *http.Request, maxSize int64) ([]byte, error)

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

func Fetch(url string) ([]byte, error)

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

func Save(url string, dir string, filename string) (string, error)

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

type ErrNotOK struct {
	URL string
	Err string
}

ErrNotOK is used when the status code is not 200 OK.

func (ErrNotOK) Error

func (e ErrNotOK) Error() string

Directories

Path Synopsis
Package header provides functions for parsing and setting HTTP headers.
Package header provides functions for parsing and setting HTTP headers.

Jump to

Keyboard shortcuts

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