code: private boolean mergeRequests(HttpRequestMessage from, HttpRequestMessage to) {
  
          if (from == null || to == null) {
              return false;
          }
  
          final URI initialRequestURI = from.getRequestURI();
          final URI extendedRequestURI = to.getRequestURI();
  
          boolean uriPathOk = initialRequestURI.getPath().equals(extendedRequestURI.getPath());
  
          if ( !uriPathOk ) {
              return false;
          }
  
          // Note: the fact that "Host" is an allowance was required by KG-3481.
          final String[] allowances = {"Host", "Sec-WebSocket-Protocol", HEADER_SEC_WEBSOCKET_EXTENSIONS, "Connection"};
          if ( HttpUtils.containsForbiddenHeaders(to, allowances) ) {
              return false;
          }
  
          final String[] restrictions = {"Authorization", "X-WebSocket-Protocol", "WebSocket-Protocol", "Sec-WebSocket-Protocol",
                                         HEADER_X_WEBSOCKET_EXTENSIONS, HEADER_WEBSOCKET_EXTENSIONS, HEADER_SEC_WEBSOCKET_EXTENSIONS};
  
          HttpUtils.restrictHeaders(to, restrictions);
  
          final String[] ignoreHeaders = {HEADER_X_WEBSOCKET_EXTENSIONS,
                                          HEADER_WEBSOCKET_EXTENSIONS,
                                          HEADER_SEC_WEBSOCKET_EXTENSIONS};
          HttpUtils.mergeHeaders(from, to, ignoreHeaders);
  
          final String[] protocolHeaders = {"X-WebSocket-Protocol", "WebSocket-Protocol", "Sec-WebSocket-Protocol"};
          HttpUtils.removeValueFromHeaders(to, protocolHeaders, EXTENDED_HANDSHAKE_PROTOCOL_NAME);
  
          HttpUtils.mergeParameters(from, to);
  
          HttpUtils.mergeCookies(from, to);
  
          return true;
          
      }
docs: Return true iff the extended request matches the initial request.
  <p/>
  This function, when returning true, additionally ensures that the extended request
  contains no illegal headers, and has had selected header elements from the initial
  request merged into the extended request.
  
  @param from  the initial request
  @param to the extended request, possibly amended with a merged set of headers.
  @return true iff the extended request is the same as the initial request.