Update dependencies (#2180)
* Update dependencies * Fix whatsmeow API changes
This commit is contained in:
32
vendor/github.com/slack-go/slack/misc.go
generated
vendored
32
vendor/github.com/slack-go/slack/misc.go
generated
vendored
@@ -7,7 +7,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
@@ -63,13 +62,12 @@ func (e *RateLimitedError) Retryable() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func fileUploadReq(ctx context.Context, path string, values url.Values, r io.Reader) (*http.Request, error) {
|
||||
func fileUploadReq(ctx context.Context, path string, r io.Reader) (*http.Request, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, path, r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.URL.RawQuery = values.Encode()
|
||||
return req, nil
|
||||
}
|
||||
|
||||
@@ -127,7 +125,7 @@ func jsonReq(ctx context.Context, endpoint string, body interface{}) (req *http.
|
||||
}
|
||||
|
||||
func parseResponseBody(body io.ReadCloser, intf interface{}, d Debug) error {
|
||||
response, err := ioutil.ReadAll(body)
|
||||
response, err := io.ReadAll(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -156,9 +154,16 @@ func postLocalWithMultipartResponse(ctx context.Context, client httpClient, meth
|
||||
func postWithMultipartResponse(ctx context.Context, client httpClient, path, name, fieldname, token string, values url.Values, r io.Reader, intf interface{}, d Debug) error {
|
||||
pipeReader, pipeWriter := io.Pipe()
|
||||
wr := multipart.NewWriter(pipeWriter)
|
||||
|
||||
errc := make(chan error)
|
||||
go func() {
|
||||
defer pipeWriter.Close()
|
||||
defer wr.Close()
|
||||
err := createFormFields(wr, values)
|
||||
if err != nil {
|
||||
errc <- err
|
||||
return
|
||||
}
|
||||
ioWriter, err := wr.CreateFormFile(fieldname, name)
|
||||
if err != nil {
|
||||
errc <- err
|
||||
@@ -174,7 +179,8 @@ func postWithMultipartResponse(ctx context.Context, client httpClient, path, nam
|
||||
return
|
||||
}
|
||||
}()
|
||||
req, err := fileUploadReq(ctx, path, values, pipeReader)
|
||||
|
||||
req, err := fileUploadReq(ctx, path, pipeReader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -200,6 +206,20 @@ func postWithMultipartResponse(ctx context.Context, client httpClient, path, nam
|
||||
}
|
||||
}
|
||||
|
||||
func createFormFields(mw *multipart.Writer, values url.Values) error {
|
||||
for key, value := range values {
|
||||
writer, err := mw.CreateFormField(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = writer.Write([]byte(value[0]))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func doPost(ctx context.Context, client httpClient, req *http.Request, parser responseParser, d Debug) error {
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
@@ -316,7 +336,7 @@ func newJSONParser(dst interface{}) responseParser {
|
||||
|
||||
func newTextParser(dst interface{}) responseParser {
|
||||
return func(resp *http.Response) error {
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user