Skip to content

Commit

Permalink
New fix for issue Atmosphere#1612
Browse files Browse the repository at this point in the history
  • Loading branch information
mvsmasiero committed May 29, 2014
1 parent 3536038 commit 68c0d1b
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,15 @@ public void onOpen(Session session, EndpointConfig endpointConfig) {

// https://issues.apache.org/bugzilla/show_bug.cgi?id=56573
// https://java.net/jira/browse/WEBSOCKET_SPEC-228
if (!requestUri.startsWith("ws://")) {
String protocol = session.isSecure() ? "wss://" : "ws://";
requestUri = new StringBuilder(protocol).append("127.0.0.1:8080").append(requestUri).toString();
if ( (!requestUri.startsWith("http://")) || (!requestUri.startsWith("https://")) ) {
if (requestUri.startsWith("/")){
String origin = ((List<String>)handshakeRequest.getHeaders().get("origin")).get(0);
requestUri = new StringBuilder(origin).append(requestUri).toString();
} else if (requestUri.startsWith("ws://")){
requestUri = requestUri.replace("ws://", "http://");
} else if (requestUri.startsWith("wss://")){
requestUri = requestUri.replace("wss://", "https://");
}
}

request = new AtmosphereRequest.Builder()
Expand Down

0 comments on commit 68c0d1b

Please sign in to comment.