@@ -104,6 +104,8 @@ class IOConnection implements IOCallback {
104
104
105
105
/** Custom Request headers used while handshaking */
106
106
private Properties headers ;
107
+
108
+ private String queryString ;
107
109
108
110
/**
109
111
* The first socket to be connected. the socket.io server does not send a
@@ -151,9 +153,7 @@ private class HearbeatTimeoutTask extends TimerTask {
151
153
*/
152
154
@ Override
153
155
public void run () {
154
- error (new SocketIOException (
155
- "Timeout Error. No heartbeat from server within life time of the socket. closing." ,
156
- lastException ));
156
+ error (new SocketIOException ( "Timeout Error. No heartbeat from server within life time of the socket. closing." , lastException ));
157
157
}
158
158
}
159
159
@@ -298,19 +298,23 @@ private void handshake() {
298
298
URLConnection connection ;
299
299
try {
300
300
setState (STATE_HANDSHAKE );
301
- url = new URL (IOConnection .this .url .toString () + SOCKET_IO_1 );
301
+
302
+ String connectionUrl = IOConnection .this .url .toString () + SOCKET_IO_1 ;
303
+ if ( this .queryString != null ) {
304
+ connectionUrl += "?" + this .queryString ;
305
+ }
306
+
307
+ url = new URL ( connectionUrl );
302
308
connection = url .openConnection ();
303
309
if (connection instanceof HttpsURLConnection ) {
304
- ((HttpsURLConnection ) connection )
305
- .setSSLSocketFactory (sslContext .getSocketFactory ());
310
+ ((HttpsURLConnection ) connection ).setSSLSocketFactory (sslContext .getSocketFactory ());
306
311
}
307
312
connection .setConnectTimeout (connectTimeout );
308
313
connection .setReadTimeout (connectTimeout );
309
314
310
315
/* Setting the request headers */
311
316
for (Entry <Object , Object > entry : headers .entrySet ()) {
312
- connection .setRequestProperty ((String ) entry .getKey (),
313
- (String ) entry .getValue ());
317
+ connection .setRequestProperty ( (String ) entry .getKey (), (String ) entry .getValue () );
314
318
}
315
319
316
320
InputStream stream = connection .getInputStream ();
@@ -338,8 +342,7 @@ private synchronized void connectTransport() {
338
342
else if (protocols .contains (XhrTransport .TRANSPORT_NAME ))
339
343
transport = XhrTransport .create (url , this );
340
344
else {
341
- error (new SocketIOException (
342
- "Server supports no available transports. You should reconfigure the server to support a available transport" ));
345
+ error (new SocketIOException ( "Server supports no available transports. You should reconfigure the server to support a available transport" ) );
343
346
return ;
344
347
}
345
348
transport .connect ();
@@ -370,13 +373,10 @@ public void ack(JsonElement... args) {
370
373
try {
371
374
array .add (o );
372
375
} catch (Exception e ) {
373
- error (new SocketIOException (
374
- "You can only put values in IOAcknowledge.ack() which can be handled by JSONArray.put()" ,
375
- e ));
376
+ error (new SocketIOException ("You can only put values in IOAcknowledge.ack() which can be handled by JSONArray.put()" , e ));
376
377
}
377
378
}
378
- IOMessage ackMsg = new IOMessage (IOMessage .TYPE_ACK , endPoint ,
379
- id + array .toString ());
379
+ IOMessage ackMsg = new IOMessage (IOMessage .TYPE_ACK , endPoint , id + array .toString ());
380
380
sendPlain (ackMsg .toString ());
381
381
}
382
382
};
@@ -410,6 +410,7 @@ private IOConnection(String url, SocketIO socket) {
410
410
try {
411
411
this .url = new URL (url );
412
412
this .urlStr = url ;
413
+ this .queryString = socket .getQueryString ();
413
414
} catch (MalformedURLException e ) {
414
415
throw new RuntimeException (e );
415
416
}
@@ -570,7 +571,7 @@ public void transportData(String text) {
570
571
.listIterator (1 );
571
572
while (fragments .hasNext ()) {
572
573
int length = Integer .parseInt (fragments .next ());
573
- String string = ( String ) fragments .next ();
574
+ String string = fragments .next ();
574
575
// Potential BUG: it is not defined if length is in bytes or
575
576
// characters. Assuming characters.
576
577
0 commit comments