Merge pull request #3049 from dotnet-maestro-bot/merge/release/2.2-to-master
[automated] Merge branch 'release/2.2' => 'master'
This commit is contained in:
commit
6d1581b734
|
|
@ -109,7 +109,7 @@ abstract class HttpClient {
|
||||||
request.setMethod("DELETE");
|
request.setMethod("DELETE");
|
||||||
return this.send(request);
|
return this.send(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<HttpResponse> delete(String url, HttpRequest options) {
|
public CompletableFuture<HttpResponse> delete(String url, HttpRequest options) {
|
||||||
options.setUrl(url);
|
options.setUrl(url);
|
||||||
options.setMethod("DELETE");
|
options.setMethod("DELETE");
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
package com.microsoft.aspnet.signalr;
|
package com.microsoft.aspnet.signalr;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -198,11 +197,7 @@ public class HubConnection {
|
||||||
|
|
||||||
logger.log(LogLevel.Debug, "Starting HubConnection");
|
logger.log(LogLevel.Debug, "Starting HubConnection");
|
||||||
if (transport == null) {
|
if (transport == null) {
|
||||||
try {
|
transport = new WebSocketTransport(url, headers, httpClient, logger);
|
||||||
transport = new WebSocketTransport(url, headers, httpClient, logger);
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
transport.setOnReceive(this.callback);
|
transport.setOnReceive(this.callback);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
package com.microsoft.aspnet.signalr;
|
package com.microsoft.aspnet.signalr;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
|
@ -20,7 +19,7 @@ class WebSocketTransport implements Transport {
|
||||||
private static final String WS = "ws";
|
private static final String WS = "ws";
|
||||||
private static final String WSS = "wss";
|
private static final String WSS = "wss";
|
||||||
|
|
||||||
public WebSocketTransport(String url, Map<String, String> headers, HttpClient client, Logger logger) throws URISyntaxException {
|
public WebSocketTransport(String url, Map<String, String> headers, HttpClient client, Logger logger) {
|
||||||
this.url = formatUrl(url);
|
this.url = formatUrl(url);
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
|
@ -31,7 +30,7 @@ class WebSocketTransport implements Transport {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatUrl(String url) throws URISyntaxException {
|
private String formatUrl(String url) {
|
||||||
if (url.startsWith(HTTPS)) {
|
if (url.startsWith(HTTPS)) {
|
||||||
url = WSS + url.substring(HTTPS.length());
|
url = WSS + url.substring(HTTPS.length());
|
||||||
} else if (url.startsWith(HTTP)) {
|
} else if (url.startsWith(HTTP)) {
|
||||||
|
|
@ -44,7 +43,7 @@ class WebSocketTransport implements Transport {
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Void> start() {
|
public CompletableFuture<Void> start() {
|
||||||
logger.log(LogLevel.Debug, "Starting Websocket connection.");
|
logger.log(LogLevel.Debug, "Starting Websocket connection.");
|
||||||
this.webSocketClient = client.createWebSocket(this.url.toString(), this.headers);
|
this.webSocketClient = client.createWebSocket(this.url, this.headers);
|
||||||
this.webSocketClient.setOnReceive((message) -> onReceive(message));
|
this.webSocketClient.setOnReceive((message) -> onReceive(message));
|
||||||
this.webSocketClient.setOnClose((code, reason) -> onClose(code, reason));
|
this.webSocketClient.setOnClose((code, reason) -> onClose(code, reason));
|
||||||
return webSocketClient.start().thenRun(() -> logger.log(LogLevel.Information, "WebSocket transport connected to: %s.", this.url));
|
return webSocketClient.start().thenRun(() -> logger.log(LogLevel.Information, "WebSocket transport connected to: %s.", this.url));
|
||||||
|
|
|
||||||
|
|
@ -66,5 +66,5 @@ class TestHttpClient extends HttpClient {
|
||||||
@Override
|
@Override
|
||||||
public WebSocketWrapper createWebSocket(String url, Map<String, String> headers) {
|
public WebSocketWrapper createWebSocket(String url, Map<String, String> headers) {
|
||||||
throw new RuntimeException("WebSockets isn't supported in testing currently.");
|
throw new RuntimeException("WebSockets isn't supported in testing currently.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue