Giter Club home page Giter Club logo

go-curl's Introduction

go-curl

No Maintenance Intended

for a maintained alternative, try andelf/go-curl

Documentation:

http://godoc.org/github.com/christophwitzko/go-curl

Options

Option Type Default
method= string GET
data= io.Reader nil
dialtimeout= time.Duration 0
readtimeout= time.Duration 0
timeout= time.Duration 0
cbinterval= time.Duration time.Second
followredirects= bool true
deadline= time.Time or time.Duration 0
maxspeed= int64 0
header= http.Header nil
disablecompression= bool false

Advanced Usage

Set monitor callback interval

curl.File("xxxx", "xxx", cb, "cbinterval=", 0.5) // 0.5 second

Curl in goroutine

con := &curl.Control{}
go curl.File("xxx", "xxx", con)
// and then get stat
st := con.Stat()
// or stop
con.Stop()
// set max speed
con.MaxSpeed(1024*10)
// cancel max speed
con.MaxSpeed(0)

Just dial

err, resp := curl.Dial("http://de.edis.at/10MB.test", "timeout=11")
fmt.Println("contentLength=", resp.ContentLength)

Useful Functions

Functions format size, speed pretty

curl.PrettySize(100000000)) // 95.4MB
curl.PrettyPer(0.345) // 34.5%
curl.PrettySpeed(1200) // 1.2KB/s
curl.PrettyDur(time.Second*66) // 1:06

Progressed io.Copy

r, _ := os.Open("infile")
w, _ := os.Create("outfile")
length := 1024*888
cb := func (st curl.IoCopyStat) error {
  fmt.Println(st.Perstr, st.Sizestr, st.Lengthstr, st.Speedstr, st.Durstr)
  return nil
}
curl.IoCopy(r, length, w, "readtimeout=12", cb)

go-curl's People

Contributors

christophwitzko avatar xieran1988 avatar nareix avatar cfanfrank avatar divinity76 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.