20
20
import java .io .UnsupportedEncodingException ;
21
21
import java .net .HttpURLConnection ;
22
22
import java .net .URL ;
23
- import java .util .HashMap ;
24
23
import java .util .Iterator ;
25
24
import java .util .List ;
26
25
import java .util .Map ;
26
+ import java .util .concurrent .ConcurrentHashMap ;
27
27
import java .util .regex .Matcher ;
28
28
import java .util .regex .Pattern ;
29
29
@@ -134,6 +134,8 @@ public static interface IXHRReceiving {
134
134
*/
135
135
public boolean receiving (ByteArrayOutputStream baos , byte b [], int off , int len );
136
136
}
137
+
138
+ public static String DEFAULT_USER_AGENT = "Java2Script/2.0.2" ;
137
139
138
140
protected int status ;
139
141
protected String statusText ;
@@ -153,7 +155,7 @@ public static interface IXHRReceiving {
153
155
protected String user ;
154
156
protected String password ;
155
157
156
- protected Map <String , String > headers = new HashMap <String , String >();
158
+ protected Map <String , String > headers = new ConcurrentHashMap <String , String >();
157
159
protected String content ;
158
160
159
161
protected boolean toAbort = false ;
@@ -442,8 +444,7 @@ private void request() {
442
444
connection .setInstanceFollowRedirects (false );
443
445
connection .setDoInput (true );
444
446
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 );
447
448
if ("post" .equalsIgnoreCase (method )) {
448
449
connection .setDoOutput (true );
449
450
connection .setRequestProperty ("Content-Type" , "application/x-www-form-urlencoded" );
0 commit comments