]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
urlget: Follow the "privacy by design" principle.
authorBruno Haible <bruno@clisp.org>
Sun, 23 Feb 2020 19:56:32 +0000 (20:56 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 23 Feb 2020 19:56:32 +0000 (20:56 +0100)
* gettext-tools/src/gnu/gettext/GetURL.java (fetch): Override the User-Agent
string, so as not to reveal the Java version to the server.

gettext-tools/src/gnu/gettext/GetURL.java

index 7ef42d174c17dad0587952ea27f25f4b0276893a..af5bd4b28b6df65600990ec9888e1f2079f919d1 100644 (file)
@@ -1,5 +1,5 @@
 /* Fetch an URL's contents.
- * Copyright (C) 2001, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2008, 2020 Free Software Foundation, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -56,7 +56,10 @@ public class GetURL {
       };
     timeoutThread.start();
     try {
-      InputStream istream = new BufferedInputStream(url.openStream());
+      URLConnection connection = url.openConnection();
+      // Override the User-Agent string, so as to not reveal the Java version.
+      connection.setRequestProperty("User-Agent", "urlget");
+      InputStream istream = new BufferedInputStream(connection.getInputStream());
       OutputStream ostream = new BufferedOutputStream(System.out);
       for (;;) {
         int b = istream.read();