< prev index next >
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/RedirectFilter.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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,10 +42,13 @@
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,13 +85,12 @@
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))
+ .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 >