fixed redirect problem (does not work for POST)

see http://forum.yacy-websuche.de/viewtopic.php?f=6&t=1068&hilit=

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4687 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 8313d58ae7
commit 8dd35f74c8

@ -203,6 +203,7 @@ public class JakartaCommonsHttpClient {
*/
public JakartaCommonsHttpResponse GET(final String uri) throws IOException {
final HttpMethod get = new GetMethod(uri);
get.setFollowRedirects(followRedirects);
return execute(get);
}
@ -217,6 +218,7 @@ public class JakartaCommonsHttpClient {
public JakartaCommonsHttpResponse HEAD(final String uri) throws IOException {
assert uri != null : "precondition violated: uri != null";
final HttpMethod head = new HeadMethod(uri);
head.setFollowRedirects(followRedirects);
return execute(head);
}
@ -235,6 +237,7 @@ public class JakartaCommonsHttpClient {
assert ins != null : "precondition violated: ins != null";
final PostMethod post = new PostMethod(uri);
post.setRequestEntity(new InputStreamRequestEntity(ins));
post.setFollowRedirects(false); // redirects in POST cause a "Entity enclosing requests cannot be redirected without user intervention" - exception
return execute(post);
}
@ -290,6 +293,7 @@ public class JakartaCommonsHttpClient {
parts = new Part[0];
}
post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
post.setFollowRedirects(false); // redirects in POST cause a "Entity enclosing requests cannot be redirected without user intervention" - exception
return execute(post);
}
@ -302,6 +306,7 @@ public class JakartaCommonsHttpClient {
final HostConfiguration hostConfig = new HostConfiguration();
hostConfig.setHost(host, port);
final HttpMethod connect = new ConnectMethod(hostConfig);
connect.setFollowRedirects(false); // there are no redirects possible for CONNECT commands as far as I know.
return execute(connect);
}
@ -391,7 +396,6 @@ public class JakartaCommonsHttpClient {
*/
private JakartaCommonsHttpResponse execute(final HttpMethod method) throws IOException, HttpException {
assert method != null : "precondition violated: method != null";
method.setFollowRedirects(followRedirects);
// set header
for (final Header header : headers) {
method.setRequestHeader(header);

Loading…
Cancel
Save