Skip to content

Commit

Permalink
Request should not fail anymore with empty Location (golang/go#49281)
Browse files Browse the repository at this point in the history
  • Loading branch information
gildas committed Dec 8, 2022
1 parent 1ed72e0 commit 2335123
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 18 deletions.
14 changes: 0 additions & 14 deletions request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,20 +767,6 @@ func (suite *RequestSuite) TestShouldFailPostingWithNonSeekerAttachmentAndAttemp
suite.Assert().Equal("request_test.failingReader", details.Value.(string))
}

func (suite *RequestSuite) TestShouldFailWithBadRedirectLocation() {
serverURL, _ := url.Parse(suite.Server.URL)
serverURL, _ = serverURL.Parse("/bad_redirect")
_, err := request.Send(&request.Options{
URL: serverURL,
Logger: suite.Logger,
}, nil)
suite.Require().Error(err, "Should have failed sending request")
suite.Logger.Errorf("Expected Error", err)
var details *url.Error
suite.Require().True(errors.As(err, &details), "Error chain should contain an URL Error")
suite.Assert().Contains(details.Error(), "response missing Location header")
}

func (suite *RequestSuite) TestShouldFailReceivingWhenTimeoutAnd1Attempt() {
serverURL, _ := url.Parse(suite.Server.URL)
serverURL, _ = serverURL.Parse("/timeout")
Expand Down
4 changes: 0 additions & 4 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,6 @@ func CreateTestServer(suite *RequestSuite) *httptest.Server {
res.Header().Add("X-Cache", "Miss form cloudfront")
res.WriteHeader(http.StatusSeeOther)
log.Infof("Redirecting to /Bo%%C3%%AEte.png")
case "/bad_redirect":
res.Header().Add("Location", "") // This is on purpose to check if the client handles this error well
res.WriteHeader(http.StatusFound)
log.Infof("Redirecting to /")
case "/results":
if _, err := res.Write([]byte(`{"code": 1234}`)); err != nil {
log.Errorf("Failed to Write response to %s %s, error: %s", req.Method, req.URL, err)
Expand Down

0 comments on commit 2335123

Please sign in to comment.