Skip to content

Commit

Permalink
Add default user-agent to http requests
Browse files Browse the repository at this point in the history
  • Loading branch information
einrobin committed Apr 1, 2021
1 parent 68fb99f commit 538872d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public static ServiceInclusion documentToInclusion(Document document) {
}

public static Path resolveApplicationPath(ServiceEnvironment environment, Path directory) throws IOException {
if (Files.notExists(directory)) {
return null;
}

String[] contents = APPLICATION_FILE_CONTENTS.get(environment);
if (contents == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static boolean download(String url, Path path) throws IOException {

public static boolean download(String url, OutputStream outputStream) throws IOException {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36");
connection.connect();

if (connection.getResponseCode() != 200) {
Expand Down

0 comments on commit 538872d

Please sign in to comment.