@@ -47,6 +47,7 @@ class ConnectionTask implements Task {
47
47
private static final long MAX_CONNECT_TIME = 75000 ;
48
48
private static final int MAX_TEXT_MESSAGE_SIZE = -1 ;
49
49
private static final int MAX_BINARY_MESSAGE_SIZE = -1 ;
50
+ private static final String WSS = "wss" ;
50
51
51
52
private final WebSocketClientFactory _factory ;
52
53
private final SparseArray <Connection > _map ;
@@ -73,17 +74,19 @@ public ConnectionTask(WebSocketClientFactory factory, SparseArray<Connection> ma
73
74
* Set cookies, if any.
74
75
*
75
76
* @param cookies
76
- * @param url
77
+ * @param host
78
+ * @param secure
77
79
*/
78
- private static void setCookie (Map <String , String > cookies , String url ) {
80
+ private static void setCookie (Map <String , String > cookies , String host , String path , boolean secure ) {
81
+ String url = String .format ("%s://%s%s" , secure ? "https" : "http" , host , path );
79
82
String cookie = CookieManager .getInstance ().getCookie (url );
80
83
81
84
if (cookie != null ) {
82
85
for (String c : cookie .split (";" )) {
83
86
String [] pair = c .split ("=" );
84
87
85
88
if (pair .length == 2 ) {
86
- cookies .put (pair [0 ], pair [1 ]);
89
+ cookies .put (pair [0 ]. trim () , pair [1 ]. trim () );
87
90
}
88
91
}
89
92
}
@@ -119,7 +122,7 @@ public void execute(String rawArgs, CallbackContext ctx) {
119
122
client .getExtensions ().add (new PerMessageDeflateExtension ());
120
123
}
121
124
122
- setCookie (client .getCookies (), uri .getHost ());
125
+ setCookie (client .getCookies (), uri .getHost (), uri . getPath (), WSS . equals ( uri . getScheme ()) );
123
126
124
127
WebSocketGenerator gen = new WebSocketGenerator (id , ctx );
125
128
0 commit comments