HttpRequestAuthenticationHandler extends HttpRequestHandlerAdapter { public static boolean isHTTPResponse(WrappedByteBuffer buf) { if ( buf.remaining() < HTTP_1_1_START_LEN) { return false; } for (int i = 0; i < HTTP_1_1_START_LEN; i++) { if (buf.getAt(i) != HTTP_1_1_START_BYTES[i]) { return false; } } return true; }  static boolean isHTTPResponse(WrappedByteBuffer buf); @Override void processOpen(HttpRequest request); @Override void setNextHandler(HttpRequestHandler handler); @Override void setListener(HttpRequestListener listener);  }
@Test public void testIsHttpResponse() { WrappedByteBuffer buf = WrappedByteBuffer.wrap(HTTP_401_RESPONSE_TEXT.getBytes()); assertEquals(true, HttpRequestAuthenticationHandler.isHTTPResponse(buf)); buf = WrappedByteBuffer.wrap(CREATE_RESPONSE_TEXT.getBytes()); assertEquals(false, HttpRequestAuthenticationHandler.isHTTPResponse(buf)); }
@Test public void testIsHttpResponseSmall() { WrappedByteBuffer buf = WrappedByteBuffer.wrap("HTTP".getBytes()); assertEquals(false, HttpRequestAuthenticationHandler.isHTTPResponse(buf)); }