< prev index next >
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/RedirectFilter.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 42,51 ****
--- 42,54 ----
static final int max_redirects = Utils.getIntegerNetProperty(
"jdk.httpclient.redirects.retrylimit", DEFAULT_MAX_REDIRECTS
);
+ // A public no-arg constructor is required by FilterFactory
+ public RedirectFilter() {}
+
@Override
public synchronized void request(HttpRequestImpl r, MultiExchange<?,?> e) throws IOException {
this.request = r;
this.client = e.client();
this.policy = client.followRedirects();
*** 82,94 ****
return null;
}
private URI getRedirectedURI(HttpHeaders headers) {
URI redirectedURI;
- String ss = headers.firstValue("Location").orElse("Not present");
redirectedURI = headers.firstValue("Location")
! .map((s) -> URI.create(s))
.orElseThrow(() -> new UncheckedIOException(
new IOException("Invalid redirection")));
// redirect could be relative to original URL, but if not
// then redirect is used.
--- 85,96 ----
return null;
}
private URI getRedirectedURI(HttpHeaders headers) {
URI redirectedURI;
redirectedURI = headers.firstValue("Location")
! .map(URI::create)
.orElseThrow(() -> new UncheckedIOException(
new IOException("Invalid redirection")));
// redirect could be relative to original URL, but if not
// then redirect is used.
< prev index next >