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

support not follow redirect for HTTP client #702

Merged
merged 11 commits into from May 1, 2020

Conversation

hothero
Copy link
Contributor

@hothero hothero commented Apr 15, 2020

Enable HTTP clients to have a config to choose whether it wants to follow HTTP redirect or not. In other words, if the HTTP client does not follow the redirect, the caller will receive 30* Status with Location header

@hothero hothero requested a review from rpatali April 15, 2020 21:16
@CLAassistant
Copy link

CLAassistant commented Apr 15, 2020

CLA assistant check
All committers have signed the CLA.

@hothero hothero force-pushed the hothero/support-not-follow-redirect branch from 2c2bf91 to 9d33b3a Compare April 20, 2020 12:32
@rpatali
Copy link
Contributor

rpatali commented Apr 20, 2020

Please add a test case with redirect set to false for a given client using example/example-gateway/config/*.yaml

@hothero hothero force-pushed the hothero/support-not-follow-redirect branch from 9d33b3a to 4ebe1eb Compare April 28, 2020 08:16
@hothero hothero force-pushed the hothero/support-not-follow-redirect branch from 4ebe1eb to 0b5485a Compare April 29, 2020 13:57
baseURL,
map[string]string{},
time.Second,
false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rpatali does this test case address your ask? in this test case, it creates the gateway via exampleGateway and use example gateway's config files. And this test case is to verify the client call doesn't follow the redirect, so the caller will receive 303 status code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine but additional also set the config value for clients.*.followRedirects = false for one of the clients in the .json to test the behavior since that is what you are going to need.

@coveralls
Copy link

coveralls commented Apr 29, 2020

Coverage Status

Coverage decreased (-0.02%) to 69.45% when pulling e0c495d on hothero/support-not-follow-redirect into dcb2b3e on master.

assert.NoError(t, err)
}

fakeNormal := func(w http.ResponseWriter, r *http.Request) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem to be used.

}

bgateway.HTTPBackends()["bar"].HandleFunc("POST", "/bar/echo", fakeEcho)
bgateway.HTTPBackends()["bar"].HandleFunc("GET", "/bar-path", fakeNormal)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem to be used, remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense, since we don't follow the redirect, we don't need it anymore.

Copy link
Contributor

@rpatali rpatali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hothero hothero merged commit b14dda3 into master May 1, 2020
@ChuntaoLu ChuntaoLu deleted the hothero/support-not-follow-redirect branch July 8, 2020 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants