Skip to content

Commit 1062ce6

Browse files
committed
Fixed a bug which could not get cookies which have secure attribute when using wss protocol
1 parent f90dde6 commit 1062ce6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/android/com/knowledgecode/cordova/websocket/ConnectionTask.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ public ConnectionTask(WebSocketClientFactory factory, SparseArray<Connection> ma
7777
* @param host
7878
* @param secure
7979
*/
80-
private static void setCookie(Map<String, String> cookies, String host, boolean secure) {
81-
String url = String.format("%s://%s", secure ? "https" : "http", host);
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);
8282
String cookie = CookieManager.getInstance().getCookie(url);
8383

8484
if (cookie != null) {
@@ -122,7 +122,7 @@ public void execute(String rawArgs, CallbackContext ctx) {
122122
client.getExtensions().add(new PerMessageDeflateExtension());
123123
}
124124

125-
setCookie(client.getCookies(), uri.getHost(), WSS.equals(uri.getScheme()));
125+
setCookie(client.getCookies(), uri.getHost(), uri.getPath(), WSS.equals(uri.getScheme()));
126126

127127
WebSocketGenerator gen = new WebSocketGenerator(id, ctx);
128128

0 commit comments

Comments
 (0)