diff options
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/aws/request')
7 files changed, 133 insertions, 54 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/connection_reset_error.go b/vendor/github.com/aws/aws-sdk-go/aws/request/connection_reset_error.go index 271da43..d9b37f4 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/request/connection_reset_error.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/connection_reset_error.go | |||
@@ -1,18 +1,17 @@ | |||
1 | // +build !appengine,!plan9 | ||
2 | |||
3 | package request | 1 | package request |
4 | 2 | ||
5 | import ( | 3 | import ( |
6 | "net" | 4 | "strings" |
7 | "os" | ||
8 | "syscall" | ||
9 | ) | 5 | ) |
10 | 6 | ||
11 | func isErrConnectionReset(err error) bool { | 7 | func isErrConnectionReset(err error) bool { |
12 | if opErr, ok := err.(*net.OpError); ok { | 8 | if strings.Contains(err.Error(), "read: connection reset") { |
13 | if sysErr, ok := opErr.Err.(*os.SyscallError); ok { | 9 | return false |
14 | return sysErr.Err == syscall.ECONNRESET | 10 | } |
15 | } | 11 | |
12 | if strings.Contains(err.Error(), "connection reset") || | ||
13 | strings.Contains(err.Error(), "broken pipe") { | ||
14 | return true | ||
16 | } | 15 | } |
17 | 16 | ||
18 | return false | 17 | return false |
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/connection_reset_error_other.go b/vendor/github.com/aws/aws-sdk-go/aws/request/connection_reset_error_other.go deleted file mode 100644 index daf9eca..0000000 --- a/vendor/github.com/aws/aws-sdk-go/aws/request/connection_reset_error_other.go +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | // +build appengine plan9 | ||
2 | |||
3 | package request | ||
4 | |||
5 | import ( | ||
6 | "strings" | ||
7 | ) | ||
8 | |||
9 | func isErrConnectionReset(err error) bool { | ||
10 | return strings.Contains(err.Error(), "connection reset") | ||
11 | } | ||
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/handlers.go b/vendor/github.com/aws/aws-sdk-go/aws/request/handlers.go index 8ef8548..627ec72 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/request/handlers.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/handlers.go | |||
@@ -59,6 +59,51 @@ func (h *Handlers) Clear() { | |||
59 | h.Complete.Clear() | 59 | h.Complete.Clear() |
60 | } | 60 | } |
61 | 61 | ||
62 | // IsEmpty returns if there are no handlers in any of the handlerlists. | ||
63 | func (h *Handlers) IsEmpty() bool { | ||
64 | if h.Validate.Len() != 0 { | ||
65 | return false | ||
66 | } | ||
67 | if h.Build.Len() != 0 { | ||
68 | return false | ||
69 | } | ||
70 | if h.Send.Len() != 0 { | ||
71 | return false | ||
72 | } | ||
73 | if h.Sign.Len() != 0 { | ||
74 | return false | ||
75 | } | ||
76 | if h.Unmarshal.Len() != 0 { | ||
77 | return false | ||
78 | } | ||
79 | if h.UnmarshalStream.Len() != 0 { | ||
80 | return false | ||
81 | } | ||
82 | if h.UnmarshalMeta.Len() != 0 { | ||
83 | return false | ||
84 | } | ||
85 | if h.UnmarshalError.Len() != 0 { | ||
86 | return false | ||
87 | } | ||
88 | if h.ValidateResponse.Len() != 0 { | ||
89 | return false | ||
90 | } | ||
91 | if h.Retry.Len() != 0 { | ||
92 | return false | ||
93 | } | ||
94 | if h.AfterRetry.Len() != 0 { | ||
95 | return false | ||
96 | } | ||
97 | if h.CompleteAttempt.Len() != 0 { | ||
98 | return false | ||
99 | } | ||
100 | if h.Complete.Len() != 0 { | ||
101 | return false | ||
102 | } | ||
103 | |||
104 | return true | ||
105 | } | ||
106 | |||
62 | // A HandlerListRunItem represents an entry in the HandlerList which | 107 | // A HandlerListRunItem represents an entry in the HandlerList which |
63 | // is being run. | 108 | // is being run. |
64 | type HandlerListRunItem struct { | 109 | type HandlerListRunItem struct { |
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/offset_reader.go b/vendor/github.com/aws/aws-sdk-go/aws/request/offset_reader.go index b0c2ef4..9370fa5 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/request/offset_reader.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/offset_reader.go | |||
@@ -15,12 +15,15 @@ type offsetReader struct { | |||
15 | closed bool | 15 | closed bool |
16 | } | 16 | } |
17 | 17 | ||
18 | func newOffsetReader(buf io.ReadSeeker, offset int64) *offsetReader { | 18 | func newOffsetReader(buf io.ReadSeeker, offset int64) (*offsetReader, error) { |
19 | reader := &offsetReader{} | 19 | reader := &offsetReader{} |
20 | buf.Seek(offset, sdkio.SeekStart) | 20 | _, err := buf.Seek(offset, sdkio.SeekStart) |
21 | if err != nil { | ||
22 | return nil, err | ||
23 | } | ||
21 | 24 | ||
22 | reader.buf = buf | 25 | reader.buf = buf |
23 | return reader | 26 | return reader, nil |
24 | } | 27 | } |
25 | 28 | ||
26 | // Close will close the instance of the offset reader's access to | 29 | // Close will close the instance of the offset reader's access to |
@@ -54,7 +57,9 @@ func (o *offsetReader) Seek(offset int64, whence int) (int64, error) { | |||
54 | 57 | ||
55 | // CloseAndCopy will return a new offsetReader with a copy of the old buffer | 58 | // CloseAndCopy will return a new offsetReader with a copy of the old buffer |
56 | // and close the old buffer. | 59 | // and close the old buffer. |
57 | func (o *offsetReader) CloseAndCopy(offset int64) *offsetReader { | 60 | func (o *offsetReader) CloseAndCopy(offset int64) (*offsetReader, error) { |
58 | o.Close() | 61 | if err := o.Close(); err != nil { |
62 | return nil, err | ||
63 | } | ||
59 | return newOffsetReader(o.buf, offset) | 64 | return newOffsetReader(o.buf, offset) |
60 | } | 65 | } |
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/request.go b/vendor/github.com/aws/aws-sdk-go/aws/request/request.go index 8f2eb3e..e7c9b2b 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/request/request.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/request.go | |||
@@ -4,6 +4,7 @@ import ( | |||
4 | "bytes" | 4 | "bytes" |
5 | "fmt" | 5 | "fmt" |
6 | "io" | 6 | "io" |
7 | "net" | ||
7 | "net/http" | 8 | "net/http" |
8 | "net/url" | 9 | "net/url" |
9 | "reflect" | 10 | "reflect" |
@@ -231,6 +232,10 @@ func (r *Request) WillRetry() bool { | |||
231 | return r.Error != nil && aws.BoolValue(r.Retryable) && r.RetryCount < r.MaxRetries() | 232 | return r.Error != nil && aws.BoolValue(r.Retryable) && r.RetryCount < r.MaxRetries() |
232 | } | 233 | } |
233 | 234 | ||
235 | func fmtAttemptCount(retryCount, maxRetries int) string { | ||
236 | return fmt.Sprintf("attempt %v/%v", retryCount, maxRetries) | ||
237 | } | ||
238 | |||
234 | // ParamsFilled returns if the request's parameters have been populated | 239 | // ParamsFilled returns if the request's parameters have been populated |
235 | // and the parameters are valid. False is returned if no parameters are | 240 | // and the parameters are valid. False is returned if no parameters are |
236 | // provided or invalid. | 241 | // provided or invalid. |
@@ -259,7 +264,18 @@ func (r *Request) SetStringBody(s string) { | |||
259 | // SetReaderBody will set the request's body reader. | 264 | // SetReaderBody will set the request's body reader. |
260 | func (r *Request) SetReaderBody(reader io.ReadSeeker) { | 265 | func (r *Request) SetReaderBody(reader io.ReadSeeker) { |
261 | r.Body = reader | 266 | r.Body = reader |
262 | r.BodyStart, _ = reader.Seek(0, sdkio.SeekCurrent) // Get the Bodies current offset. | 267 | |
268 | if aws.IsReaderSeekable(reader) { | ||
269 | var err error | ||
270 | // Get the Bodies current offset so retries will start from the same | ||
271 | // initial position. | ||
272 | r.BodyStart, err = reader.Seek(0, sdkio.SeekCurrent) | ||
273 | if err != nil { | ||
274 | r.Error = awserr.New(ErrCodeSerialization, | ||
275 | "failed to determine start of request body", err) | ||
276 | return | ||
277 | } | ||
278 | } | ||
263 | r.ResetBody() | 279 | r.ResetBody() |
264 | } | 280 | } |
265 | 281 | ||
@@ -330,16 +346,15 @@ func getPresignedURL(r *Request, expire time.Duration) (string, http.Header, err | |||
330 | return r.HTTPRequest.URL.String(), r.SignedHeaderVals, nil | 346 | return r.HTTPRequest.URL.String(), r.SignedHeaderVals, nil |
331 | } | 347 | } |
332 | 348 | ||
333 | func debugLogReqError(r *Request, stage string, retrying bool, err error) { | 349 | const ( |
350 | notRetrying = "not retrying" | ||
351 | ) | ||
352 | |||
353 | func debugLogReqError(r *Request, stage, retryStr string, err error) { | ||
334 | if !r.Config.LogLevel.Matches(aws.LogDebugWithRequestErrors) { | 354 | if !r.Config.LogLevel.Matches(aws.LogDebugWithRequestErrors) { |
335 | return | 355 | return |
336 | } | 356 | } |
337 | 357 | ||
338 | retryStr := "not retrying" | ||
339 | if retrying { | ||
340 | retryStr = "will retry" | ||
341 | } | ||
342 | |||
343 | r.Config.Logger.Log(fmt.Sprintf("DEBUG: %s %s/%s failed, %s, error %v", | 358 | r.Config.Logger.Log(fmt.Sprintf("DEBUG: %s %s/%s failed, %s, error %v", |
344 | stage, r.ClientInfo.ServiceName, r.Operation.Name, retryStr, err)) | 359 | stage, r.ClientInfo.ServiceName, r.Operation.Name, retryStr, err)) |
345 | } | 360 | } |
@@ -358,12 +373,12 @@ func (r *Request) Build() error { | |||
358 | if !r.built { | 373 | if !r.built { |
359 | r.Handlers.Validate.Run(r) | 374 | r.Handlers.Validate.Run(r) |
360 | if r.Error != nil { | 375 | if r.Error != nil { |
361 | debugLogReqError(r, "Validate Request", false, r.Error) | 376 | debugLogReqError(r, "Validate Request", notRetrying, r.Error) |
362 | return r.Error | 377 | return r.Error |
363 | } | 378 | } |
364 | r.Handlers.Build.Run(r) | 379 | r.Handlers.Build.Run(r) |
365 | if r.Error != nil { | 380 | if r.Error != nil { |
366 | debugLogReqError(r, "Build Request", false, r.Error) | 381 | debugLogReqError(r, "Build Request", notRetrying, r.Error) |
367 | return r.Error | 382 | return r.Error |
368 | } | 383 | } |
369 | r.built = true | 384 | r.built = true |
@@ -379,7 +394,7 @@ func (r *Request) Build() error { | |||
379 | func (r *Request) Sign() error { | 394 | func (r *Request) Sign() error { |
380 | r.Build() | 395 | r.Build() |
381 | if r.Error != nil { | 396 | if r.Error != nil { |
382 | debugLogReqError(r, "Build Request", false, r.Error) | 397 | debugLogReqError(r, "Build Request", notRetrying, r.Error) |
383 | return r.Error | 398 | return r.Error |
384 | } | 399 | } |
385 | 400 | ||
@@ -387,12 +402,16 @@ func (r *Request) Sign() error { | |||
387 | return r.Error | 402 | return r.Error |
388 | } | 403 | } |
389 | 404 | ||
390 | func (r *Request) getNextRequestBody() (io.ReadCloser, error) { | 405 | func (r *Request) getNextRequestBody() (body io.ReadCloser, err error) { |
391 | if r.safeBody != nil { | 406 | if r.safeBody != nil { |
392 | r.safeBody.Close() | 407 | r.safeBody.Close() |
393 | } | 408 | } |
394 | 409 | ||
395 | r.safeBody = newOffsetReader(r.Body, r.BodyStart) | 410 | r.safeBody, err = newOffsetReader(r.Body, r.BodyStart) |
411 | if err != nil { | ||
412 | return nil, awserr.New(ErrCodeSerialization, | ||
413 | "failed to get next request body reader", err) | ||
414 | } | ||
396 | 415 | ||
397 | // Go 1.8 tightened and clarified the rules code needs to use when building | 416 | // Go 1.8 tightened and clarified the rules code needs to use when building |
398 | // requests with the http package. Go 1.8 removed the automatic detection | 417 | // requests with the http package. Go 1.8 removed the automatic detection |
@@ -409,10 +428,10 @@ func (r *Request) getNextRequestBody() (io.ReadCloser, error) { | |||
409 | // Related golang/go#18257 | 428 | // Related golang/go#18257 |
410 | l, err := aws.SeekerLen(r.Body) | 429 | l, err := aws.SeekerLen(r.Body) |
411 | if err != nil { | 430 | if err != nil { |
412 | return nil, awserr.New(ErrCodeSerialization, "failed to compute request body size", err) | 431 | return nil, awserr.New(ErrCodeSerialization, |
432 | "failed to compute request body size", err) | ||
413 | } | 433 | } |
414 | 434 | ||
415 | var body io.ReadCloser | ||
416 | if l == 0 { | 435 | if l == 0 { |
417 | body = NoBody | 436 | body = NoBody |
418 | } else if l > 0 { | 437 | } else if l > 0 { |
@@ -473,13 +492,13 @@ func (r *Request) Send() error { | |||
473 | r.AttemptTime = time.Now() | 492 | r.AttemptTime = time.Now() |
474 | 493 | ||
475 | if err := r.Sign(); err != nil { | 494 | if err := r.Sign(); err != nil { |
476 | debugLogReqError(r, "Sign Request", false, err) | 495 | debugLogReqError(r, "Sign Request", notRetrying, err) |
477 | return err | 496 | return err |
478 | } | 497 | } |
479 | 498 | ||
480 | if err := r.sendRequest(); err == nil { | 499 | if err := r.sendRequest(); err == nil { |
481 | return nil | 500 | return nil |
482 | } else if !shouldRetryCancel(r.Error) { | 501 | } else if !shouldRetryError(r.Error) { |
483 | return err | 502 | return err |
484 | } else { | 503 | } else { |
485 | r.Handlers.Retry.Run(r) | 504 | r.Handlers.Retry.Run(r) |
@@ -489,13 +508,16 @@ func (r *Request) Send() error { | |||
489 | return r.Error | 508 | return r.Error |
490 | } | 509 | } |
491 | 510 | ||
492 | r.prepareRetry() | 511 | if err := r.prepareRetry(); err != nil { |
512 | r.Error = err | ||
513 | return err | ||
514 | } | ||
493 | continue | 515 | continue |
494 | } | 516 | } |
495 | } | 517 | } |
496 | } | 518 | } |
497 | 519 | ||
498 | func (r *Request) prepareRetry() { | 520 | func (r *Request) prepareRetry() error { |
499 | if r.Config.LogLevel.Matches(aws.LogDebugWithRequestRetries) { | 521 | if r.Config.LogLevel.Matches(aws.LogDebugWithRequestRetries) { |
500 | r.Config.Logger.Log(fmt.Sprintf("DEBUG: Retrying Request %s/%s, attempt %d", | 522 | r.Config.Logger.Log(fmt.Sprintf("DEBUG: Retrying Request %s/%s, attempt %d", |
501 | r.ClientInfo.ServiceName, r.Operation.Name, r.RetryCount)) | 523 | r.ClientInfo.ServiceName, r.Operation.Name, r.RetryCount)) |
@@ -506,12 +528,19 @@ func (r *Request) prepareRetry() { | |||
506 | // the request's body even though the Client's Do returned. | 528 | // the request's body even though the Client's Do returned. |
507 | r.HTTPRequest = copyHTTPRequest(r.HTTPRequest, nil) | 529 | r.HTTPRequest = copyHTTPRequest(r.HTTPRequest, nil) |
508 | r.ResetBody() | 530 | r.ResetBody() |
531 | if err := r.Error; err != nil { | ||
532 | return awserr.New(ErrCodeSerialization, | ||
533 | "failed to prepare body for retry", err) | ||
534 | |||
535 | } | ||
509 | 536 | ||
510 | // Closing response body to ensure that no response body is leaked | 537 | // Closing response body to ensure that no response body is leaked |
511 | // between retry attempts. | 538 | // between retry attempts. |
512 | if r.HTTPResponse != nil && r.HTTPResponse.Body != nil { | 539 | if r.HTTPResponse != nil && r.HTTPResponse.Body != nil { |
513 | r.HTTPResponse.Body.Close() | 540 | r.HTTPResponse.Body.Close() |
514 | } | 541 | } |
542 | |||
543 | return nil | ||
515 | } | 544 | } |
516 | 545 | ||
517 | func (r *Request) sendRequest() (sendErr error) { | 546 | func (r *Request) sendRequest() (sendErr error) { |
@@ -520,7 +549,9 @@ func (r *Request) sendRequest() (sendErr error) { | |||
520 | r.Retryable = nil | 549 | r.Retryable = nil |
521 | r.Handlers.Send.Run(r) | 550 | r.Handlers.Send.Run(r) |
522 | if r.Error != nil { | 551 | if r.Error != nil { |
523 | debugLogReqError(r, "Send Request", r.WillRetry(), r.Error) | 552 | debugLogReqError(r, "Send Request", |
553 | fmtAttemptCount(r.RetryCount, r.MaxRetries()), | ||
554 | r.Error) | ||
524 | return r.Error | 555 | return r.Error |
525 | } | 556 | } |
526 | 557 | ||
@@ -528,13 +559,17 @@ func (r *Request) sendRequest() (sendErr error) { | |||
528 | r.Handlers.ValidateResponse.Run(r) | 559 | r.Handlers.ValidateResponse.Run(r) |
529 | if r.Error != nil { | 560 | if r.Error != nil { |
530 | r.Handlers.UnmarshalError.Run(r) | 561 | r.Handlers.UnmarshalError.Run(r) |
531 | debugLogReqError(r, "Validate Response", r.WillRetry(), r.Error) | 562 | debugLogReqError(r, "Validate Response", |
563 | fmtAttemptCount(r.RetryCount, r.MaxRetries()), | ||
564 | r.Error) | ||
532 | return r.Error | 565 | return r.Error |
533 | } | 566 | } |
534 | 567 | ||
535 | r.Handlers.Unmarshal.Run(r) | 568 | r.Handlers.Unmarshal.Run(r) |
536 | if r.Error != nil { | 569 | if r.Error != nil { |
537 | debugLogReqError(r, "Unmarshal Response", r.WillRetry(), r.Error) | 570 | debugLogReqError(r, "Unmarshal Response", |
571 | fmtAttemptCount(r.RetryCount, r.MaxRetries()), | ||
572 | r.Error) | ||
538 | return r.Error | 573 | return r.Error |
539 | } | 574 | } |
540 | 575 | ||
@@ -565,13 +600,13 @@ type temporary interface { | |||
565 | Temporary() bool | 600 | Temporary() bool |
566 | } | 601 | } |
567 | 602 | ||
568 | func shouldRetryCancel(err error) bool { | 603 | func shouldRetryError(origErr error) bool { |
569 | switch err := err.(type) { | 604 | switch err := origErr.(type) { |
570 | case awserr.Error: | 605 | case awserr.Error: |
571 | if err.Code() == CanceledErrorCode { | 606 | if err.Code() == CanceledErrorCode { |
572 | return false | 607 | return false |
573 | } | 608 | } |
574 | return shouldRetryCancel(err.OrigErr()) | 609 | return shouldRetryError(err.OrigErr()) |
575 | case *url.Error: | 610 | case *url.Error: |
576 | if strings.Contains(err.Error(), "connection refused") { | 611 | if strings.Contains(err.Error(), "connection refused") { |
577 | // Refused connections should be retried as the service may not yet | 612 | // Refused connections should be retried as the service may not yet |
@@ -581,14 +616,17 @@ func shouldRetryCancel(err error) bool { | |||
581 | } | 616 | } |
582 | // *url.Error only implements Temporary after golang 1.6 but since | 617 | // *url.Error only implements Temporary after golang 1.6 but since |
583 | // url.Error only wraps the error: | 618 | // url.Error only wraps the error: |
584 | return shouldRetryCancel(err.Err) | 619 | return shouldRetryError(err.Err) |
585 | case temporary: | 620 | case temporary: |
621 | if netErr, ok := err.(*net.OpError); ok && netErr.Op == "dial" { | ||
622 | return true | ||
623 | } | ||
586 | // If the error is temporary, we want to allow continuation of the | 624 | // If the error is temporary, we want to allow continuation of the |
587 | // retry process | 625 | // retry process |
588 | return err.Temporary() | 626 | return err.Temporary() || isErrConnectionReset(origErr) |
589 | case nil: | 627 | case nil: |
590 | // `awserr.Error.OrigErr()` can be nil, meaning there was an error but | 628 | // `awserr.Error.OrigErr()` can be nil, meaning there was an error but |
591 | // because we don't know the cause, it is marked as retriable. See | 629 | // because we don't know the cause, it is marked as retryable. See |
592 | // TestRequest4xxUnretryable for an example. | 630 | // TestRequest4xxUnretryable for an example. |
593 | return true | 631 | return true |
594 | default: | 632 | default: |
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/request_1_8.go b/vendor/github.com/aws/aws-sdk-go/aws/request/request_1_8.go index 7c6a800..de1292f 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/request/request_1_8.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/request_1_8.go | |||
@@ -4,6 +4,8 @@ package request | |||
4 | 4 | ||
5 | import ( | 5 | import ( |
6 | "net/http" | 6 | "net/http" |
7 | |||
8 | "github.com/aws/aws-sdk-go/aws/awserr" | ||
7 | ) | 9 | ) |
8 | 10 | ||
9 | // NoBody is a http.NoBody reader instructing Go HTTP client to not include | 11 | // NoBody is a http.NoBody reader instructing Go HTTP client to not include |
@@ -24,7 +26,8 @@ var NoBody = http.NoBody | |||
24 | func (r *Request) ResetBody() { | 26 | func (r *Request) ResetBody() { |
25 | body, err := r.getNextRequestBody() | 27 | body, err := r.getNextRequestBody() |
26 | if err != nil { | 28 | if err != nil { |
27 | r.Error = err | 29 | r.Error = awserr.New(ErrCodeSerialization, |
30 | "failed to reset request body", err) | ||
28 | return | 31 | return |
29 | } | 32 | } |
30 | 33 | ||
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/request_pagination.go b/vendor/github.com/aws/aws-sdk-go/aws/request/request_pagination.go index a633ed5..f093fc5 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/request/request_pagination.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/request_pagination.go | |||
@@ -146,7 +146,7 @@ func (r *Request) nextPageTokens() []interface{} { | |||
146 | return nil | 146 | return nil |
147 | } | 147 | } |
148 | case bool: | 148 | case bool: |
149 | if v == false { | 149 | if !v { |
150 | return nil | 150 | return nil |
151 | } | 151 | } |
152 | } | 152 | } |