Added support for Authorization header

This commit is contained in:
Norbert.Nogacki@tomtom.com 2019-05-17 16:22:28 +02:00
parent b9df1f2278
commit a53416b4da
2 changed files with 14 additions and 14 deletions

View File

@ -83,7 +83,9 @@ You can set all the following variables:
* `PLANTUML_STATS`
* Set it to `on` to enable [statistics report](http://plantuml.com/statistics-report)
* Default value `off`
* `HTTP_AUTHORIZATION`
* when calling the `proxy` endpoint, the value of `HTTP_AUTHORIZATION` will be used to set the HTTP Authorization header
* Default value: null
Alternate: How to build your docker image

View File

@ -135,20 +135,18 @@ public class ProxyServlet extends HttpServlet {
}
private HttpURLConnection getConnection(final URL url) throws IOException {
if (url.getProtocol().startsWith("https")) {
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setReadTimeout(10000); // 10 seconds
// printHttpsCert(con);
con.connect();
return con;
} else {
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setReadTimeout(10000); // 10 seconds
con.connect();
return con;
final HttpURLConnection con = (HttpURLConnection) url.openConnection();
if (con instanceof HttpsURLConnection) {
// printHttpsCert((HttpsURLConnection) con);
}
con.setRequestMethod("GET");
String token = System.getenv("HTTP_AUTHORIZATION");
if (token != null) {
con.setRequestProperty("Authorization", token);
}
con.setReadTimeout(10000); // 10 seconds
con.connect();
return con;
}
/**