Advertisement
Guest User

method

a guest
Feb 6th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1. private StatusLine readStatusLine(WebSocketInputStream input) throws WebSocketException
  2.     {
  3.         String line;
  4.  
  5.         try
  6.         {
  7.             // Read the status line.
  8.             line = input.readLine();
  9.         }
  10.         catch (IOException e)
  11.         {
  12.             // Failed to read an opening handshake response from the server.
  13.             throw new WebSocketException(
  14.                 WebSocketError.OPENING_HANDSHAKE_RESPONSE_FAILURE,
  15.                 "Failed to read an opening handshake response from the server: " + e.getMessage(), e);
  16.         }
  17.  
  18.         if (line == null || line.length() == 0)
  19.         {
  20.             // The status line of the opening handshake response is empty.
  21.             throw new WebSocketException(
  22.                 WebSocketError.STATUS_LINE_EMPTY,
  23.                 "The status line of the opening handshake response is empty.");
  24.         }
  25.  
  26.         try
  27.         {
  28.             // Parse the status line.
  29.             return new StatusLine(line);
  30.         }
  31.         catch (Exception e)
  32.         {
  33.             // The status line of the opening handshake response is badly formatted.
  34.             throw new WebSocketException(
  35.                 WebSocketError.STATUS_LINE_BAD_FORMAT,
  36.                 "The status line of the opening handshake response is badly formatted. The status line is: " + line);
  37.         }
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement