Skip to content

Latest commit

 

History

History

compression

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

gentleman/compression Build Status GoDoc API Go Report Card

gentleman's plugin to disable and customize data compression in HTTP requests/responses.

Installation

go get -u gopkg.in/h2non/gentleman.v2/plugins/compression

API

See godoc reference.

Example

package main

import (
  "fmt"
  "gopkg.in/h2non/gentleman.v2"
  "gopkg.in/h2non/gentleman.v2/plugins/compression"
)

func main() {
  // Create a new client
  cli := gentleman.New()

  // Disable HTTP compression
  cli.Use(compression.Disable())

  // Perform the request
  res, err := cli.Request().URL("http://httpbin.org/gzip").Send()
  if err != nil {
    fmt.Printf("Request error: %s\n", err)
    return
  }
  if !res.Ok {
    fmt.Printf("Invalid server response: %d\n", res.StatusCode)
    return
  }

  fmt.Printf("Status: %d\n", res.StatusCode)
  fmt.Printf("Body: %s", res.String())
}

License

MIT - Tomas Aparicio