Repository navigation
Make retries duplicate-safe and refuse cross-host redirects - #41
Merged
Merged
Conversation
Retries could deliver a notification twice: - SMTP: a failed QUIT after the server accepted DATA was a net.Error, hence retried. Ignore QUIT errors once DATA is accepted, and treat network errors while the end of DATA is acknowledged as permanent. 4xx replies stay retryable since they mean the message was refused. - HTTP: timeouts after the request was written and 500s were retried. Only dial/DNS failures and 429/502/503/504 are temporary now. Go's client follows 307/308 to any host and re-sends the body and custom headers (X-Api-Key, form tokens). Follow redirects only within the original host. Fixes #32 Fixes #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #32, fixes #34 (both from the fresh review, reproduced there).
Retries no longer duplicate (
Temporary= nothing was delivered or server explicitly said retry):Redirects:
CheckRedirectfollows only same-host hops (max 10); cross-host →refusing redirect to another host (...). Go otherwise re-sends the body and non-Authorizationheaders on 307/308. The client is now always a dedicatedhttp.Client(insecure mode still clonesDefaultTransport).README, flag help, and example comment describe what is retried.
Tests: status classification table, timeout-after-send not temporary, cross-host redirect refused and target never hit, same-host redirect followed, ambiguous SMTP net error permanent, fake SMTP server dropping the connection after 250 →
Sendsucceeds.