private StatusLine readStatusLine ( WebSocketInputStream input ) throws WebSocketException { String line ; try { // Read the status line. line = input . readLine ( ) ; } catch ( IOException e ) { // Failed to read an opening handshake response from the server. throw new WebSocketException ( WebSocketError . OPENING_HANDSHAKE_RESPONSE_FAILURE , "Failed to read an opening handshake response from the server: " + e . getMessage ( ) , e ) ; } if ( line == null || line . length ( ) == 0 ) { // The status line of the opening handshake response is empty. throw new WebSocketException ( WebSocketError . STATUS_LINE_EMPTY , "The status line of the opening handshake response is empty." ) ; } try { // Parse the status line. return new StatusLine ( line ) ; } catch ( Exception e ) { // The status line of the opening handshake response is badly formatted. throw new WebSocketException ( WebSocketError . STATUS_LINE_BAD_FORMAT , "The status line of the opening handshake response is badly formatted. The status line is: " + line ) ; } }
Read a status line from an HTTP server .