forked from TrueCloudLab/rclone
vendor: update all dependencies
This commit is contained in:
parent
17b4058ee9
commit
abb9f89f65
443 changed files with 32118 additions and 18237 deletions
40
vendor/github.com/putdotio/go-putio/putio/client.go
generated
vendored
40
vendor/github.com/putdotio/go-putio/putio/client.go
generated
vendored
|
@ -3,7 +3,6 @@ package putio
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
@ -31,6 +30,9 @@ type Client struct {
|
|||
// User agent for client
|
||||
UserAgent string
|
||||
|
||||
// Override host header for API requests
|
||||
Host string
|
||||
|
||||
// ExtraHeaders are passed to the API server on every request.
|
||||
ExtraHeaders http.Header
|
||||
|
||||
|
@ -79,7 +81,8 @@ func (c *Client) ValidateToken(ctx context.Context) (userID *int64, err error) {
|
|||
var r struct {
|
||||
UserID *int64 `json:"user_id"`
|
||||
}
|
||||
_, err = c.Do(req, &r)
|
||||
resp, err := c.Do(req, &r)
|
||||
defer resp.Body.Close()
|
||||
return r.UserID, err
|
||||
}
|
||||
|
||||
|
@ -109,6 +112,10 @@ func (c *Client) NewRequest(ctx context.Context, method, relURL string, body io.
|
|||
req.Header.Set("Accept", defaultMediaType)
|
||||
req.Header.Set("User-Agent", c.UserAgent)
|
||||
|
||||
if c.Host != "" {
|
||||
req.Host = c.Host
|
||||
}
|
||||
|
||||
// merge headers with extra headers
|
||||
for header, values := range c.ExtraHeaders {
|
||||
for _, value := range values {
|
||||
|
@ -156,25 +163,22 @@ func (c *Client) Do(r *http.Request, v interface{}) (*http.Response, error) {
|
|||
// status code is not in success range, it will try to return a structured
|
||||
// error.
|
||||
func checkResponse(r *http.Response) error {
|
||||
status := r.StatusCode
|
||||
switch {
|
||||
case status >= 200 && status <= 399:
|
||||
if r.StatusCode >= 200 && r.StatusCode <= 399 {
|
||||
return nil
|
||||
case status >= 400 && status <= 599:
|
||||
// server returns json
|
||||
default:
|
||||
return fmt.Errorf("unexpected status code: %d", status)
|
||||
}
|
||||
errorResponse := &ErrorResponse{Response: r}
|
||||
data, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("body read error: %s. status: %v. Details: %v:", err, status, string(data[:250]))
|
||||
|
||||
// server possibly returns json and more details
|
||||
er := &ErrorResponse{Response: r}
|
||||
|
||||
er.Body, er.ParseError = ioutil.ReadAll(r.Body)
|
||||
if er.ParseError != nil {
|
||||
return er
|
||||
}
|
||||
if len(data) > 0 {
|
||||
err = json.Unmarshal(data, errorResponse)
|
||||
if err != nil {
|
||||
return fmt.Errorf("json decode error: %s. status: %v. Details: %v:", err, status, string(data[:250]))
|
||||
if r.Header.Get("content-type") == "application/json" {
|
||||
er.ParseError = json.Unmarshal(er.Body, er)
|
||||
if er.ParseError != nil {
|
||||
return er
|
||||
}
|
||||
}
|
||||
return errorResponse
|
||||
return er
|
||||
}
|
||||
|
|
16
vendor/github.com/putdotio/go-putio/putio/error.go
generated
vendored
16
vendor/github.com/putdotio/go-putio/putio/error.go
generated
vendored
|
@ -7,19 +7,31 @@ import (
|
|||
|
||||
// ErrorResponse reports the error caused by an API request.
|
||||
type ErrorResponse struct {
|
||||
// Original http.Response
|
||||
Response *http.Response `json:"-"`
|
||||
|
||||
// Body read from Response
|
||||
Body []byte `json:"-"`
|
||||
|
||||
// Error while parsing the response
|
||||
ParseError error
|
||||
|
||||
// These fileds are parsed from response if JSON.
|
||||
Message string `json:"error_message"`
|
||||
Type string `json:"error_type"`
|
||||
}
|
||||
|
||||
func (e *ErrorResponse) Error() string {
|
||||
if e.ParseError != nil {
|
||||
return fmt.Errorf("cannot parse response. code:%d error:%q body:%q",
|
||||
e.Response.StatusCode, e.ParseError.Error(), string(e.Body[:250])).Error()
|
||||
}
|
||||
return fmt.Sprintf(
|
||||
"Type: %v Message: %q. Original error: %v %v: %v",
|
||||
"putio error. code:%d type:%q message:%q request:%v %v",
|
||||
e.Response.StatusCode,
|
||||
e.Type,
|
||||
e.Message,
|
||||
e.Response.Request.Method,
|
||||
e.Response.Request.URL,
|
||||
e.Response.Status,
|
||||
)
|
||||
}
|
||||
|
|
1
vendor/github.com/putdotio/go-putio/putio/events.go
generated
vendored
1
vendor/github.com/putdotio/go-putio/putio/events.go
generated
vendored
|
@ -24,7 +24,6 @@ func (e *EventsService) List(ctx context.Context) ([]Event, error) {
|
|||
return nil, err
|
||||
}
|
||||
return r.Events, nil
|
||||
|
||||
}
|
||||
|
||||
// Delete Clears all all dashboard events.
|
||||
|
|
6
vendor/github.com/putdotio/go-putio/putio/files.go
generated
vendored
6
vendor/github.com/putdotio/go-putio/putio/files.go
generated
vendored
|
@ -202,7 +202,7 @@ func (f *FilesService) Move(ctx context.Context, parent int64, files ...int64) e
|
|||
|
||||
// Upload reads from given io.Reader and uploads the file contents to Put.io
|
||||
// servers under directory given by parent. If parent is negative, user's
|
||||
// prefered folder is used.
|
||||
// preferred folder is used.
|
||||
//
|
||||
// If the uploaded file is a torrent file, Put.io will interpret it as a
|
||||
// transfer and Transfer field will be present to represent the status of the
|
||||
|
@ -219,7 +219,7 @@ func (f *FilesService) Upload(ctx context.Context, r io.Reader, filename string,
|
|||
var buf bytes.Buffer
|
||||
mw := multipart.NewWriter(&buf)
|
||||
|
||||
// negative parent means use user's prefered download folder.
|
||||
// negative parent means use user's preferred download folder.
|
||||
if parent >= 0 {
|
||||
err := mw.WriteField("parent_id", itoa(parent))
|
||||
if err != nil {
|
||||
|
@ -322,7 +322,7 @@ func (f *FilesService) sharedWith(ctx context.Context, id int64) ([]share, error
|
|||
return r.Shared, nil
|
||||
}
|
||||
|
||||
// Subtitles lists available subtitles for the given file for user's prefered
|
||||
// Subtitles lists available subtitles for the given file for user's preferred
|
||||
// subtitle language.
|
||||
func (f *FilesService) Subtitles(ctx context.Context, id int64) ([]Subtitle, error) {
|
||||
req, err := f.client.NewRequest(ctx, "GET", "/v2/files/"+itoa(id)+"/subtitles", nil)
|
||||
|
|
3
vendor/github.com/putdotio/go-putio/putio/go.mod
generated
vendored
Normal file
3
vendor/github.com/putdotio/go-putio/putio/go.mod
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
module github.com/putdotio/go-putio/putio
|
||||
|
||||
go 1.13
|
1
vendor/github.com/putdotio/go-putio/putio/zips.go
generated
vendored
1
vendor/github.com/putdotio/go-putio/putio/zips.go
generated
vendored
|
@ -26,7 +26,6 @@ func (z *ZipsService) Get(ctx context.Context, id int64) (Zip, error) {
|
|||
}
|
||||
|
||||
return r, nil
|
||||
|
||||
}
|
||||
|
||||
// List lists active zip files.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue