Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update websocket dependency #520

Merged
merged 17 commits into from
Nov 15, 2019
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
15a0552
Add Maven Central repository
paddybyers Nov 1, 2019
4b512ef
Update java-websocket dependency
paddybyers Nov 1, 2019
fadd232
HttpUtils: fix encodeURIComponent() wrt handling of space
paddybyers Nov 1, 2019
b5790f6
RawProtocolListener: add onRawConnectRequested()
paddybyers Nov 1, 2019
6bb4a16
ConnectionManager: ensure that a connection attempt that is interrupt…
paddybyers Nov 1, 2019
a8d5596
Auth.timeDelta: make this instance-wide, not static, to avoid test in…
paddybyers Nov 4, 2019
c1fead9
Defaults: correct disconnect retry delay to 15s
paddybyers Nov 8, 2019
f96f86a
Helpers.ConnectionWaiter: add some logging
paddybyers Nov 8, 2019
9962924
WebSocketTransport: ensure that async events are propagated in a sepa…
paddybyers Nov 8, 2019
24b4930
ConnectionManager: fix connection retry regression
paddybyers Nov 8, 2019
31b38c1
RestSuite: revert accidentially-committed disabled tests
paddybyers Nov 8, 2019
e71c7eb
RealtimeAuthTest: don't overwrite static defaults, and increase test …
paddybyers Nov 8, 2019
9bd0885
WebsocketTransport: ensure that the timer exists always, not only whe…
paddybyers Nov 11, 2019
d073edb
WebsocketTransport: stop using deprecated setSocket() for SSL
paddybyers Nov 11, 2019
d179cfa
ConnectionManagerTest: avoid use of race-prone ConnectionManagerWaite…
paddybyers Nov 15, 2019
6a81179
RestPushTest: @Ignore list_channels test, which fails randomly due to…
paddybyers Nov 15, 2019
12ba625
ConnectionManagerTest: @Ignore tests that are not valid tests for the…
paddybyers Nov 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 24 additions & 13 deletions lib/src/main/java/io/ably/lib/http/HttpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -138,19 +139,29 @@ public static String getParam(Param[] params, String key) {
return result;
}

public static String encodeURIComponent(String input) {
try {
return URLEncoder.encode(input, "UTF-8")
.replaceAll(" ", "%20")
.replaceAll("!", "%21")
.replaceAll("'", "%27")
.replaceAll("\\(", "%28")
.replaceAll("\\)", "%29")
.replaceAll("\\+", "%2B")
.replaceAll("\\:", "%3A")
.replaceAll("~", "%7E");
} catch (UnsupportedEncodingException e) {}
return null;
/* copied from https://stackoverflow.com/a/52378025 */
private static final String HEX = "0123456789ABCDEF";

public static String encodeURIComponent(String str) {
paddybyers marked this conversation as resolved.
Show resolved Hide resolved
if (str == null) {
return null;
}

byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
StringBuilder builder = new StringBuilder(bytes.length);

for (byte c : bytes) {
if (c >= 'a' ? c <= 'z' || c == '~' :
c >= 'A' ? c <= 'Z' || c == '_' :
c >= '0' ? c <= '9' : c == '-' || c == '.')
builder.append((char)c);
else
builder.append('%')
.append(HEX.charAt(c >> 4 & 0xf))
.append(HEX.charAt(c & 0xf));
}

return builder.toString();
}

private static void appendParams(StringBuilder uri, Param[] params) {
Expand Down