#8606 closed defect (fixed)
For JOSM webstart version the user agent is not set
Reported by: | stoecker | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core Webstart | Version: | |
Keywords: | Cc: |
Description
When the webstart is used, the user agent is simply Java/... and no longer the josm agent.
It seems the user agent value is cached somewhere, as the http.agent property is correct, but it is not used.
See also: http://wiki.nikhef.nl/grid/JGridstart/Java_user_agents for a fix (would mean to reintroduce the User-Agent header setting with a slight modification.
Attachments (2)
Change History (21)
comment:1 by , 11 years ago
by , 11 years ago
Attachment: | 8606.patch added |
---|
follow-up: 7 comment:5 by , 11 years ago
Still not all. E.g. icons when loading a help page have wrong agent.
comment:7 by , 11 years ago
Replying to stoecker:
Still not all. E.g. icons when loading a help page have wrong agent.
Yes, reproduced also.
comment:8 by , 11 years ago
Summary: | For JOSM webstart version the user agent is not set → [Patch] For JOSM webstart version the user agent is not set |
---|
As I understand the problem: When using Web Start, The JVM makes a HTTP request to download our jar file, thus initiates on its own the Java HTTP internal mechanism. This results in running the following code before JOSM starts, in sun.net.www.protocol.http.HttpURLConnection
:
public static final String userAgent; static { String agent = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("http.agent")); if (agent == null) { agent = "Java/"+version; } else { agent = agent + " Java/"+version; } userAgent = agent; }
The variable userAgent
is then used to set the User-Agent property for all HTTP connections created by Java. It works as expected when we are not in Web Start, because there is not a single HTTP URL created before we set the Java property "http.agent".
I first thought about modifying this variable using Java reflection, but it is not allowed for static final variables.
I have a working solution (to reproduce the problem and simulate Web Start behaviour, it is enough to add System.out.println(HttpURLConnection.userAgent);
as the first instruction run by JOSM in its main method), but it is ugly as hell.
Not sure if there's a simpler and cleaner fix.
comment:9 by , 11 years ago
Pretty neat! ;)
An alternative would be to add something like this to the .jnlp file:
<java> <java-vm-args>-Dhttp.agent="JOSM/1.5 r1234"</java-vm-args> </java>
(untested)
But this way, we cannot add information like OS and locale, so your solution is probably better.
follow-up: 11 comment:10 by , 11 years ago
I think lets wait some days, maybe we'll find a better solution (probably asking at stackoverflow if someone else has a tipp?) and when not use this patch.
follow-up: 12 comment:11 by , 11 years ago
Replying to stoecker:
I think lets wait some days, maybe we'll find a better solution (probably asking at stackoverflow if someone else has a tipp?) and when not use this patch.
I asked on StackOverflow (my first question !). Let's see there...
comment:12 by , 11 years ago
Replying to Don-vip:
Replying to stoecker:
I think lets wait some days, maybe we'll find a better solution (probably asking at stackoverflow if someone else has a tipp?) and when not use this patch.
I asked on StackOverflow (my first question !). Let's see there...
I increased the question value by one :-)
comment:16 by , 11 years ago
Looks like there is no easy solution to this problem.
I have manually setup the User-Agent to some other connections.
Are some some connections remaining, apart the <img> resolutions ? If it's the only one that we cannot fix, I think we can live with it, and not apply this patch, as its gain is not worth the risks it introduces.
comment:17 by , 11 years ago
Summary: | [Patch] For JOSM webstart version the user agent is not set → For JOSM webstart version the user agent is not set |
---|
comment:18 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:19 by , 4 years ago
Component: | Core → Core Webstart |
---|
The fix again has the problem, that e.g. the wiki reader uses another user agent in this case.