2020import java .io .UnsupportedEncodingException ;
2121import java .net .HttpURLConnection ;
2222import java .net .URL ;
23- import java .util .HashMap ;
2423import java .util .Iterator ;
2524import java .util .List ;
2625import java .util .Map ;
26+ import java .util .concurrent .ConcurrentHashMap ;
2727import java .util .regex .Matcher ;
2828import java .util .regex .Pattern ;
2929
@@ -134,6 +134,8 @@ public static interface IXHRReceiving {
134134 */
135135 public boolean receiving (ByteArrayOutputStream baos , byte b [], int off , int len );
136136 }
137+
138+ public static String DEFAULT_USER_AGENT = "Java2Script/2.0.2" ;
137139
138140 protected int status ;
139141 protected String statusText ;
@@ -153,7 +155,7 @@ public static interface IXHRReceiving {
153155 protected String user ;
154156 protected String password ;
155157
156- protected Map <String , String > headers = new HashMap <String , String >();
158+ protected Map <String , String > headers = new ConcurrentHashMap <String , String >();
157159 protected String content ;
158160
159161 protected boolean toAbort = false ;
@@ -442,8 +444,7 @@ private void request() {
442444 connection .setInstanceFollowRedirects (false );
443445 connection .setDoInput (true );
444446 connection .setRequestMethod (method );
445- connection .setRequestProperty ("User-Agent" ,
446- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36" );
447+ connection .setRequestProperty ("User-Agent" , DEFAULT_USER_AGENT );
447448 if ("post" .equalsIgnoreCase (method )) {
448449 connection .setDoOutput (true );
449450 connection .setRequestProperty ("Content-Type" , "application/x-www-form-urlencoded" );
0 commit comments