pluto

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2017 License: GPL-2.0 Imports: 10 Imported by: 2

Documentation

Overview

Package pluto provides a way to download files at high speeds by using http ranged requests.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrOverflow is when server sends more data than what was requested
	ErrOverflow = "error: Server sent extra bytes"
)

Functions

func Download

func Download(c *Config) error

Download takes Config struct then downloads the file by dividing it into given number of parts and downloading all parts concurrently. If any error occurs in the downloading stage of any part, It'll check if the the program can recover from error by retrying download And if an error occurs which the program can not recover from, it'll return that error

Types

type Config

type Config struct {
	Connections uint
	Verbose     bool
	Headers     []string
	Writer      io.WriterAt
	Meta        *FileMeta
	StatsChan   chan *Stats
	// contains filtered or unexported fields
}

Config contains all the details that Download needs. Connections is the number of connections to use to download a file Verbose is to enable verbose mode. Writer is the place where downloaded data is written. Headers is any header that you may need to send to download the file. StatsChan is a channel to which Stats are sent, It can be nil or a channel that can hold data of type *()

type FileMeta

type FileMeta struct {
	Size               uint64
	Name               string
	MultipartSupported bool
	// contains filtered or unexported fields
}

FileMeta contains information about the file like it's Size, Name and if the server supports multipart downloads

func FetchMeta

func FetchMeta(u *url.URL, headers []string) (*FileMeta, error)

FetchMeta fetches information about the file like it's Size, Name and if it supports Multipart Download If a link does not supports multipart downloads, Then the provided value of part is ignored and set to 1

type Stats added in v1.5.1

type Stats struct {
	Downloaded uint64
	Speed      uint64
}

Stats is returned in a channel by Download function every 250ms and contains details like Current download speed in bytes/sec and amount of data Downloaded

Jump to

Keyboard shortcuts

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