From c8fe23519e66963a2eb837a2c1209ffae8300ddd Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 23 Feb 2020 20:56:32 +0100 Subject: [PATCH] urlget: Follow the "privacy by design" principle. * 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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gettext-tools/src/gnu/gettext/GetURL.java b/gettext-tools/src/gnu/gettext/GetURL.java index 7ef42d174..af5bd4b28 100644 --- a/gettext-tools/src/gnu/gettext/GetURL.java +++ b/gettext-tools/src/gnu/gettext/GetURL.java @@ -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(); -- 2.47.3