TestDefaultRedirectStrategy.java (httpcomponents-client-4.5.7-src) | : | TestDefaultRedirectStrategy.java (httpcomponents-client-4.5.8-src) | ||
---|---|---|---|---|
skipping to change at line 388 | skipping to change at line 388 | |||
final HttpPost httppost = new HttpPost("http://localhost/"); | final HttpPost httppost = new HttpPost("http://localhost/"); | |||
final HttpEntity entity = new BasicHttpEntity(); | final HttpEntity entity = new BasicHttpEntity(); | |||
httppost.setEntity(entity); | httppost.setEntity(entity); | |||
final HttpUriRequest redirect2 = redirectStrategy.getRedirect( | final HttpUriRequest redirect2 = redirectStrategy.getRedirect( | |||
httppost, response, context2); | httppost, response, context2); | |||
Assert.assertEquals("POST", redirect2.getMethod()); | Assert.assertEquals("POST", redirect2.getMethod()); | |||
Assert.assertTrue(redirect2 instanceof HttpEntityEnclosingRequest); | Assert.assertTrue(redirect2 instanceof HttpEntityEnclosingRequest); | |||
Assert.assertSame(entity, ((HttpEntityEnclosingRequest) redirect2).getEn tity()); | Assert.assertSame(entity, ((HttpEntityEnclosingRequest) redirect2).getEn tity()); | |||
} | } | |||
@Test | ||||
public void testCreateLocationURI() throws Exception { | ||||
final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStra | ||||
tegy(); | ||||
Assert.assertEquals("http://blahblah/", | ||||
redirectStrategy.createLocationURI("http://BlahBlah").toASCIIStr | ||||
ing()); | ||||
} | ||||
@Test(expected=ProtocolException.class) | @Test(expected=ProtocolException.class) | |||
public void testCreateLocationURIInvalid() throws Exception { | public void testCreateLocationURIInvalid() throws Exception { | |||
final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStra tegy(); | final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStra tegy(); | |||
redirectStrategy.createLocationURI(":::::::"); | redirectStrategy.createLocationURI(":::::::"); | |||
} | } | |||
@Test | ||||
public void testWithoutNormalize() throws Exception { | ||||
final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStra | ||||
tegy(); | ||||
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1 | ||||
, | ||||
HttpStatus.SC_TEMPORARY_REDIRECT, "Temporary Redirect"); | ||||
response.addHeader("Location", "http://somewhere.com//foo"); | ||||
final HttpClientContext context1 = new HttpClientContext(new BasicHttpCo | ||||
ntext()); | ||||
context1.setRequestConfig(RequestConfig.custom().setNormalizeUri(false). | ||||
build()); | ||||
Assert.assertEquals("http://somewhere.com//foo", redirectStrategy.getRed | ||||
irect( | ||||
new HttpGet("http://localhost/stuff"), response, context1).getURI(). | ||||
toASCIIString()); | ||||
} | ||||
} | } | |||
End of changes. 2 change blocks. | ||||
9 lines changed or deleted | 17 lines changed or added |