Newsfeed: use a custom HTTP User-Agent 64/20864/3
Clément DAVID [Mon, 18 Feb 2019 16:40:36 +0000 (17:40 +0100)]
Change-Id: I1316680c33b2e6ef287c9e2fd3638bb75a826b3f

scilab/modules/core/src/java/org/scilab/modules/core/Scilab.java

index 5e790a9..f9b5bf6 100644 (file)
@@ -31,6 +31,7 @@ import javax.swing.SwingUtilities;
 import org.flexdock.docking.DockingConstants;
 import org.flexdock.docking.DockingManager;
 import org.scilab.modules.commons.OS;
+import org.scilab.modules.commons.ScilabCommons;
 import org.scilab.modules.commons.ScilabCommonsUtils;
 import org.scilab.modules.commons.ScilabConstants;
 import org.scilab.modules.commons.xml.XConfiguration;
@@ -112,6 +113,13 @@ public class Scilab {
                 /* In this case, we let the calling application to use its own properties */
                 System.setProperty("java.io.tmpdir", ScilabConstants.TMPDIR.getCanonicalPath());
                 System.setProperty("user.home", ScilabConstants.SCIHOME.getCanonicalPath());
+
+                /* build a standard User-Agent string */
+                StringBuilder str = new StringBuilder();
+                str.append("Scilab/").append(ScilabCommons.getScilabVersionMajor()).append('.').append(ScilabCommons.getScilabVersionMinor()).append('.').append(ScilabCommons.getScilabVersionMaintenance());
+                str.append(' ');
+                str.append('(').append(System.getProperty("os.name")).append(' ').append(System.getProperty("os.arch")).append(')');
+                System.setProperty("http.agent", str.toString());
             }
 
         } catch (Exception e) {
@@ -126,7 +134,7 @@ public class Scilab {
          */
         setJOGLFlags();
         /* Mode GUI */
-        if(mode == 2) {
+        if (mode == 2) {
             SwingView.registerSwingView();
         }