List of usage examples for io.netty.handler.codec.http HttpResponseStatus UPGRADE_REQUIRED
HttpResponseStatus UPGRADE_REQUIRED
To view the source code for io.netty.handler.codec.http HttpResponseStatus UPGRADE_REQUIRED.
Click Source Link
From source file:jj.http.server.websocket.WebSocketConnectionMaker.java
License:Apache License
public void handshakeWebsocket() { final WebSocketServerHandshaker handshaker = handshakerFactory.newHandshaker(request); if (handshaker == null) { response.header(Names.SEC_WEBSOCKET_VERSION, WebSocketVersion.V13.toHttpHeaderValue()) .sendError(HttpResponseStatus.UPGRADE_REQUIRED); } else {//from w w w . j a v a2s . c o m doHandshake(ctx, request, handshaker); } }
From source file:jj.http.server.websocket.WebSocketConnectionMakerTest.java
License:Apache License
@Test public void testBadWebSocketRequest() throws Exception { // given/*from w w w . j av a 2s .com*/ given(handshakerFactory.newHandshaker(request)).willReturn(null); // when wscm.handshakeWebsocket(); // then verify(response).header(HttpHeaders.Names.SEC_WEBSOCKET_VERSION, WebSocketVersion.V13.toHttpHeaderValue()); verify(response).sendError(HttpResponseStatus.UPGRADE_REQUIRED); }
From source file:org.wisdom.engine.server.CommonResponses.java
License:Apache License
/** * Return that we are not compatible with the requested the web socket version. * * @param channel the channel/* ww w . j av a 2 s .com*/ */ public static void sendUnsupportedWebSocketVersionResponse(Channel channel) { HttpResponse res = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.UPGRADE_REQUIRED); res.headers().set(HttpHeaders.Names.SEC_WEBSOCKET_VERSION, WebSocketVersion.V13.toHttpHeaderValue()); channel.write(res); }