tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grigorov <mgrigo...@apache.org>
Subject Re: svn commit: r1642721 - /tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
Date Mon, 01 Dec 2014 19:12:09 GMT
Hi,

On Mon, Dec 1, 2014 at 6:55 PM, <remm@apache.org> wrote:

> Author: remm
> Date: Mon Dec  1 17:55:07 2014
> New Revision: 1642721
>
> URL: http://svn.apache.org/r1642721
> Log:
> Try a better origin header.
>
> Modified:
>     tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
>
> Modified:
> tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
> URL:
> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java?rev=1642721&r1=1642720&r2=1642721&view=diff
>
> ==============================================================================
> ---
> tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
> (original)
> +++
> tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java Mon
> Dec  1 17:55:07 2014
> @@ -224,8 +224,6 @@ public class WsWebSocketContainer
>          clientEndpointConfiguration.getConfigurator().
>                  beforeRequest(reqHeaders);
>
> -        ByteBuffer request = createRequest(path, reqHeaders);
> -
>          SocketAddress sa;
>          if (port == -1) {
>              if ("ws".equalsIgnoreCase(scheme)) {
> @@ -244,6 +242,20 @@ public class WsWebSocketContainer
>              sa = new InetSocketAddress(host, port);
>          }
>
> +        // Origin header
> +        if (!reqHeaders.containsKey(Constants.ORIGIN_HEADER_NAME)) {
>



> +            List<String> originValues = new ArrayList<>(1);
> +            StringBuffer originValue = new StringBuffer();
>

Prefer StringBuilder than StringBuffer for local variables to avoid
unnecessary synchronizations.


> +
> originValue.append(path.getScheme()).append("://").append(path.getHost());
> +            if (port != -1) {
> +                originValue.append(':').append(port);
> +            }
> +            originValues.add(originValue.toString());
> +            reqHeaders.put(Constants.ORIGIN_HEADER_NAME, originValues);
> +        }
> +
> +        ByteBuffer request = createRequest(path, reqHeaders);
> +
>          AsynchronousSocketChannel socketChannel;
>          try {
>              socketChannel =
> AsynchronousSocketChannel.open(getAsynchronousChannelGroup());
> @@ -476,11 +488,6 @@ public class WsWebSocketContainer
>                      generateExtensionHeaders(extensions));
>          }
>
> -        // Origin header
> -        List<String> originValues = new ArrayList<>(1);
> -        originValues.add(path.toString());
> -        headers.put(Constants.ORIGIN_HEADER_NAME, originValues);
> -
>          return headers;
>      }
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message