protected boolean doValidate ( HttpRequestMessage request , final boolean isPostMethodAllowed ) { if ( ! isPostMethodAllowed ) { if ( request . getMethod ( ) != HttpMethod . GET ) { return false ; } } else { if ( request . getMethod ( ) != HttpMethod . GET || request . getMethod ( ) == HttpMethod . POST ) { return false ; } } if ( request . getVersion ( ) != HttpVersion . HTTP_1_1 ) { return false ; } if ( request . getRequestURI ( ) == null ) { return false ; } boolean ok = requireHeader ( request , "Connection" , "Upgrade" ) ; if ( ! ok ) { return false ; } ok = requireHeader ( request , "Upgrade" , "WebSocket" ) ; if ( ! ok ) { return false ; } ok = requireHeader ( request , "Host" ) ; return ok ; }
Does the provided request form a valid web socket handshake request?