On 01/12/2014 17:55, r...@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.

This is an improvement since it is not just the scheme, host and port
but it still reflects the connection being made to WebSocket rather than
the Origin of the request. I don't see how the WebSocketContainer can
possibly determine what the origin is. It has to rely on a user provided
value.

Also, I don't see anything in either RFC6455 or the Java WebSocket
specification that says that the origin header is mandatory.

Mark


> 
> 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();
> +            
> 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-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to