Examples of IncompleteHandshakeException


Examples of org.java_websocket.exceptions.IncompleteHandshakeException

      if( !response.getFieldValue( "Sec-WebSocket-Origin" ).equals( request.getFieldValue( "Origin" ) ) || !basicAccept( response ) ) {
        return HandshakeState.NOT_MATCHED;
      }
      byte[] content = response.getContent();
      if( content == null || content.length == 0 ) {
        throw new IncompleteHandshakeException();
      }
      if( Arrays.equals( content, createChallenge( request.getFieldValue( "Sec-WebSocket-Key1" ), request.getFieldValue( "Sec-WebSocket-Key2" ), request.getContent() ) ) ) {
        return HandshakeState.MATCHED;
      } else {
        return HandshakeState.NOT_MATCHED;
View Full Code Here

Examples of org.java_websocket.exceptions.IncompleteHandshakeException

    if( ( bui.hasFieldValue( "Sec-WebSocket-Key1" ) || role == Role.CLIENT ) && !bui.hasFieldValue( "Sec-WebSocket-Version" ) ) {
      byte[] key3 = new byte[ role == Role.SERVER ? 8 : 16 ];
      try {
        buf.get( key3 );
      } catch ( BufferUnderflowException e ) {
        throw new IncompleteHandshakeException( buf.capacity() + 16 );
      }
      bui.setContent( key3 );

    }
    return bui;
View Full Code Here

Examples of org.java_websocket.exceptions.IncompleteHandshakeException

  public static HandshakeBuilder translateHandshakeHttp( ByteBuffer buf, Role role ) throws InvalidHandshakeException , IncompleteHandshakeException {
    HandshakeBuilder handshake;

    String line = readStringLine( buf );
    if( line == null )
      throw new IncompleteHandshakeException( buf.capacity() + 128 );

    String[] firstLineTokens = line.split( " ", 3 );// eg. HTTP/1.1 101 Switching the Protocols
    if( firstLineTokens.length != 3 ) {
      throw new InvalidHandshakeException();
    }

    if( role == Role.CLIENT ) {
      // translating/parsing the response from the SERVER
      handshake = new HandshakeImpl1Server();
      ServerHandshakeBuilder serverhandshake = (ServerHandshakeBuilder) handshake;
      serverhandshake.setHttpStatus( Short.parseShort( firstLineTokens[ 1 ] ) );
      serverhandshake.setHttpStatusMessage( firstLineTokens[ 2 ] );
    } else {
      // translating/parsing the request from the CLIENT
      ClientHandshakeBuilder clienthandshake = new HandshakeImpl1Client();
      clienthandshake.setResourceDescriptor( firstLineTokens[ 1 ] );
      handshake = clienthandshake;
    }

    line = readStringLine( buf );
    while ( line != null && line.length() > 0 ) {
      String[] pair = line.split( ":", 2 );
      if( pair.length != 2 )
        throw new InvalidHandshakeException( "not an http header" );
      handshake.put( pair[ 0 ], pair[ 1 ].replaceFirst( "^ +", "" ) );
      line = readStringLine( buf );
    }
    if( line == null )
      throw new IncompleteHandshakeException();
    return handshake;
  }
View Full Code Here

Examples of org.java_websocket.exceptions.IncompleteHandshakeException

  private HandshakeState isFlashEdgeCase( ByteBuffer request ) throws IncompleteHandshakeException {
    request.mark();
    if( request.limit() > Draft.FLASH_POLICY_REQUEST.length ) {
      return HandshakeState.NOT_MATCHED;
    } else if( request.limit() < Draft.FLASH_POLICY_REQUEST.length ) {
      throw new IncompleteHandshakeException( Draft.FLASH_POLICY_REQUEST.length );
    } else {

      for( int flash_policy_index = 0 ; request.hasRemaining() ; flash_policy_index++ ) {
        if( Draft.FLASH_POLICY_REQUEST[ flash_policy_index ] != request.get() ) {
          request.reset();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.