respreader

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2021 License: MIT Imports: 10 Imported by: 0

README

HTTP reader with automatic content decompression

Usage

Supported http content encodings: gzip, deflate, br (aka Brotli format)

package main

import (
	"github.com/oripio/respreader"
	"log"
	"net/http"
)

func main() {
	url := "https://google.com/"

	client := http.Client{}
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		log.Fatal(err)
	}

	resp, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()

	bresp, err := respreader.Decode(resp)
	if err != nil {
		log.Fatal(err)
	}

	log.Print(string(bresp))
}

License

Brotli and these bindings are open-sourced under the MIT License - see the LICENSE file.

Documentation

Index

Constants

View Source
const (
	TypeGZIP    = "gzip"
	TypeZLIB    = "zlib"
	TypeDeflate = "deflate"
	TypeBrotli  = "br"
)

Variables

This section is empty.

Functions

func Decode

func Decode(Response *http.Response) ([]byte, error)

func DecodeBytes

func DecodeBytes(buffer []byte, algo string) ([]byte, error)

func EncodeBytes

func EncodeBytes(buffer []byte, algo string) ([]byte, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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