Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev into master #545

Merged
merged 45 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2e08a55
Deserialize additionalInfo in ARM error
j5lim Jun 13, 2018
03b8d03
Merge branch 'master' of https://github.com/azure/go-autorest into dev
jhendrixMSFT Jul 10, 2018
60d22e3
Allow a new authorizer to be created from a configuration file by spe…
nphmuller Sep 4, 2018
07f5297
[WIP] Using the Context from the timeout if provided (#315)
tombuildsstuff Sep 28, 2018
47d499b
Add NewAuthorizerFromCli method which uses Azure CLI to obtain a toke…
nphmuller Oct 4, 2018
e4490bb
Merge branch 'master' into dev
jhendrixMSFT Oct 9, 2018
0b5e8cb
Merge branch 'master' into dev
jhendrixMSFT Oct 19, 2018
e3e073a
Adding User assigned identity support for the MSIConfig authorizor (#…
samkreter Oct 19, 2018
463d23c
Merge branch 'master' into dev
jhendrixMSFT May 20, 2019
b3989e6
Adding ByteSlicePtr (#399)
draychev May 20, 2019
6dadc53
Adding a new `WithXML` method (#402)
tombuildsstuff May 31, 2019
98c2976
Add HTTP status code response helpers (#403)
jhendrixMSFT Jun 5, 2019
ae1b5cf
adding a new preparer for `MERGE` used in the Storage API's (#406)
tombuildsstuff Jun 19, 2019
a6c3224
New Preparer/Responder for `Unmarshalling Bytes` (#407)
tombuildsstuff Jun 19, 2019
851f98c
Support HTTP-Date in Retry-After header (#410)
jhendrixMSFT Jun 20, 2019
bb605b3
Merge branch 'master' into dev
jhendrixMSFT Jun 21, 2019
ef48668
Add support for multi-tenant authentication (#412)
jhendrixMSFT Jun 25, 2019
31ab60d
rename Options to OAuthOptions (#415)
jhendrixMSFT Jul 1, 2019
76904d2
Merge branch 'master' into dev
jhendrixMSFT Jul 3, 2019
a0512ab
Support custom SendDecorator chains via context (#417)
jhendrixMSFT Jul 8, 2019
1affb82
merge master into dev (#427)
jhendrixMSFT Jul 10, 2019
7340d42
Merge branch 'master' into dev
jhendrixMSFT Jul 23, 2019
3722f8c
Merge branch 'master' into dev
jhendrixMSFT Sep 4, 2019
6d8e7e7
Use accessTokens.json from AZURE_CONFIG_DIR if AZURE_ACCESS_TOKEN_FIL…
pdecat Oct 7, 2019
056d5c6
Merge branch 'master' of https://github.com/azure/go-autorest into dev
jhendrixMSFT Oct 17, 2019
0b055be
Merge branch 'dev' of https://github.com/azure/go-autorest into dev
jhendrixMSFT Oct 17, 2019
87a0e43
support for parsing error messages from xml responses (#465)
tombuildsstuff Oct 21, 2019
e6b2fe5
fix godoc comment for methods that are safe for concurrent use (#475)
tabboud Oct 21, 2019
a5c6556
New Authorizers for Azure Storage (#416)
tombuildsstuff Oct 22, 2019
5f1f2ad
Adding a new Authorizer for SAS Token Authentication (#478)
tombuildsstuff Oct 23, 2019
7820109
token: support for a custom refresh func (#476)
tombuildsstuff Oct 23, 2019
f8ee05f
Fix Dropped Errors (#480)
alrs Oct 30, 2019
be77dbd
Duration order consistency when multiplying number by time unit (#499)
maxifom Feb 4, 2020
81b386e
Merge branch 'master' of https://github.com/Azure/go-autorest into dev
jhendrixMSFT Feb 5, 2020
ee2a686
Drain response bodies (#432)
jhendrixMSFT Feb 5, 2020
4aad125
Enable exponential back-off when retrying on 429 (#503)
jhendrixMSFT Feb 6, 2020
2e06601
Merge branch 'master' into dev
jhendrixMSFT May 28, 2020
5ac3904
Expose OAuth token provider for use outside autorest (#520)
alespour Jun 5, 2020
18c897a
Fix Go module ambiguous import errors (#528)
miquella Jun 23, 2020
c25826a
Merge branch 'master' into dev
jhendrixMSFT Jun 23, 2020
6badcf9
Update resourceManagerVMDNSSuffix for AzureUSGovernmentCloud (#531)
panicstevenson Jun 23, 2020
5bb054f
This endpoint changed in AzureChinaCloud (#530)
MaurGi Jun 23, 2020
dadf295
Merge branch 'master' into dev
jhendrixMSFT Aug 5, 2020
b8633a5
allow MSI login with "mi_res_id" (#544)
haitch Aug 6, 2020
be79144
Merge branch 'master' into dev
jhendrixMSFT Aug 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Support HTTP-Date in Retry-After header (#410)
RFC specifies Retry-After header can be integer value expressing seconds
or an HTTP-Date indicating when to try again.
Removed superfluous check for HTTP status code.
  • Loading branch information
jhendrixMSFT committed Jun 20, 2019
commit 851f98c37329c0dc6d31d7450309a0215bf5cb20
18 changes: 13 additions & 5 deletions autorest/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,24 @@ func DoRetryForStatusCodes(attempts int, backoff time.Duration, codes ...int) Se
}
}

// DelayWithRetryAfter invokes time.After for the duration specified in the "Retry-After" header in
// responses with status code 429
// DelayWithRetryAfter invokes time.After for the duration specified in the "Retry-After" header.
// The value of Retry-After can be either the number of seconds or a date in RFC1123 format.
// The function returns true after successfully waiting for the specified duration. If there is
// no Retry-After header or the wait is cancelled the return value is false.
func DelayWithRetryAfter(resp *http.Response, cancel <-chan struct{}) bool {
if resp == nil {
return false
}
retryAfter, _ := strconv.Atoi(resp.Header.Get("Retry-After"))
if resp.StatusCode == http.StatusTooManyRequests && retryAfter > 0 {
var dur time.Duration
ra := resp.Header.Get("Retry-After")
if retryAfter, _ := strconv.Atoi(ra); retryAfter > 0 {
dur = time.Duration(retryAfter) * time.Second
} else if t, err := time.Parse(time.RFC1123, ra); err == nil {
dur = t.Sub(time.Now())
}
if dur > 0 {
select {
case <-time.After(time.Duration(retryAfter) * time.Second):
case <-time.After(dur):
return true
case <-cancel:
return false
Expand Down
27 changes: 27 additions & 0 deletions autorest/sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,33 @@ func TestDelayWithRetryAfterWithSuccess(t *testing.T) {
}
}

func TestDelayWithRetryAfterWithSuccessDateTime(t *testing.T) {
resumeAt := time.Now().Add(2 * time.Second).Round(time.Second)

client := mocks.NewSender()
resp := mocks.NewResponseWithStatus("503 Service temporarily unavailable", http.StatusServiceUnavailable)
mocks.SetResponseHeader(resp, "Retry-After", resumeAt.Format(time.RFC1123))
client.AppendResponse(resp)
client.AppendResponse(mocks.NewResponseWithStatus("200 OK", http.StatusOK))

r, _ := SendWithSender(client, mocks.NewRequest(),
DoRetryForStatusCodes(1, time.Duration(time.Second), http.StatusServiceUnavailable),
)

if time.Now().Before(resumeAt) {
t.Fatal("autorest: DelayWithRetryAfter failed stopped too soon")
}

Respond(r,
ByDiscardingBody(),
ByClosing())

if client.Attempts() != 2 {
t.Fatalf("autorest: Sender#DelayWithRetryAfter -- Got: StatusCode %v in %v attempts; Want: StatusCode 200 OK in 2 attempts -- ",
r.Status, client.Attempts()-1)
}
}

type temporaryError struct {
message string
}
Expand Down