Skip to content

Commit

Permalink
Add retry for 0 StatusCode (#78)
Browse files Browse the repository at this point in the history
* Add retry for 0 StatusCode

Signed-off-by: Saswata Mukherjee <[email protected]>

* Add changelog

Signed-off-by: Saswata Mukherjee <[email protected]>

* Add comment

Signed-off-by: Saswata Mukherjee <[email protected]>
  • Loading branch information
saswatamcode authored Aug 30, 2021
1 parent d68d51d commit e6f8545
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel
* [#71](https://github.com/bwplotka/mdox/pull/71) Add `Origin.Path` to transform template
* [#75](https://github.com/bwplotka/mdox/pull/75) Add `soft-wraps` flag to preserve soft line breaks
* [#76](https://github.com/bwplotka/mdox/pull/76) Add `linkPrefixForNonMarkdownResources` to transform config
* [#78](https://github.com/bwplotka/mdox/pull/78) Add retry for 0 StatusCode

### Fixed

Expand Down
3 changes: 2 additions & 1 deletion pkg/mdformatter/linktransformer/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ func NewValidator(ctx context.Context, logger log.Logger, linksValidateConfig []
break
}
v.remoteLinks[response.Ctx.Get(originalURLKey)] = errors.Wrapf(err, "%q rate limited even after retry; status code %v", response.Request.URL.String(), response.StatusCode)
case http.StatusMovedPermanently, http.StatusTemporaryRedirect, http.StatusServiceUnavailable:
// 0 StatusCode means error on call side.
case http.StatusMovedPermanently, http.StatusTemporaryRedirect, http.StatusServiceUnavailable, 0:
if retries > 0 {
break
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/mdformatter/linktransformer/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func TestValidator_TransformDestination(t *testing.T) {
))
testutil.NotOk(t, err)
testutil.Equals(t, fmt.Sprintf("%v: 2 errors: "+
"%v:1: \"https://docs.gfoogle.com/drawings/d/e/2PACX-1vTBFK_cGMbxFpYcv/pub?w=960&h=720\" not accessible; status code 0: Get \"https://docs.gfoogle.com/drawings/d/e/2PACX-1vTBFK_cGMbxFpYcv/pub?w=960&h=720\": dial tcp: lookup docs.gfoogle.com: no such host; "+
"%v:1: \"https://docs.gfoogle.com/drawings/d/e/2PACX-1vTBFK_cGMbxFpYcv/pub?w=960&h=720\" not accessible even after retry; status code 0: Get \"https://docs.gfoogle.com/drawings/d/e/2PACX-1vTBFK_cGMbxFpYcv/pub?w=960&h=720\": dial tcp: lookup docs.gfoogle.com: no such host; "+
"%v:1: \"https://bwplotka.dev/does-not-exists\" not accessible; status code 404: Not Found", tmpDir+filePath, relDirPath+filePath, relDirPath+filePath), err.Error())
})

Expand Down

0 comments on commit e6f8545

Please sign in to comment.