-
Notifications
You must be signed in to change notification settings - Fork 959
Disable following redirects on UrlConnectionHttpClient #989
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "category": "URLConnection HTTP Client", | ||
| "type": "bugfix", | ||
| "description": "Disable following redirects automatically since doing so causes SDK response handling to fail" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
|
||
| import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; | ||
| import com.github.tomakehurst.wiremock.junit.WireMockRule; | ||
| import java.io.ByteArrayInputStream; | ||
| import java.io.IOException; | ||
|
|
@@ -129,8 +130,15 @@ protected void testForResponseCodeUsingHttps(SdkHttpClient client, int returnCod | |
| } | ||
|
|
||
| private void stubForMockRequest(int returnCode) { | ||
| stubFor(any(urlPathEqualTo("/")).willReturn( | ||
| aResponse().withStatus(returnCode).withHeader("Some-Header", "With Value").withBody("hello"))); | ||
| ResponseDefinitionBuilder responseBuilder = aResponse().withStatus(returnCode) | ||
| .withHeader("Some-Header", "With Value") | ||
| .withBody("hello"); | ||
|
|
||
| if (returnCode >= 300 && returnCode <= 399) { | ||
| responseBuilder.withHeader("Location", "Some New Location"); | ||
| } | ||
|
||
|
|
||
| stubFor(any(urlPathEqualTo("/")).willReturn(responseBuilder)); | ||
| } | ||
|
|
||
| private void validateResponse(HttpExecuteResponse response, int returnCode) throws IOException { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment why we do this?