1
0
mirror of https://github.com/octoleo/plantuml-server.git synced 2024-11-18 02:05:12 +00:00

Merge pull request #105 from norbitheeviljester/master

Added support for Authorization header
This commit is contained in:
arnaudroques 2019-05-17 18:07:37 +02:00 committed by GitHub
commit cd65d5719a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;
}
/**