List of usage examples for io.netty.handler.codec.http HttpMethod GET
HttpMethod GET
To view the source code for io.netty.handler.codec.http HttpMethod GET.
Click Source Link
From source file:jj.http.server.HttpServerResponseImplTest.java
License:Apache License
@Before public void before() { nettyRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/"); nettyRequest.headers().add(HttpHeaders.Names.HOST, host); request = new HttpServerRequestImpl(nettyRequest, new RouteFinder(), ctx); response = new HttpServerResponseImpl(version, request, ctx, publisher); assertThat(response.charset(), is(UTF_8)); }
From source file:jj.http.server.websocket.WebSocketRequestChecker.java
License:Apache License
public boolean isWebSocketRequest(final FullHttpRequest request) { return HttpMethod.GET.equals(request.getMethod()) && isUpgradeRequest(request) && HttpHeaders.Values.WEBSOCKET.equalsIgnoreCase(request.headers().get(HttpHeaders.Names.UPGRADE)) && isWebSocketURI(request); }
From source file:jj.http.server.websocket.WebSocketRequestCheckerTest.java
License:Apache License
@Test public void testMatchesWebSocketRequest() { request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, socketUri); request.headers().add(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.UPGRADE) .add(HttpHeaders.Names.UPGRADE, HttpHeaders.Values.WEBSOCKET); assertThat(wsrc.isWebSocketRequest(request), is(true)); request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/some/uri"); request.headers().add(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.UPGRADE) .add(HttpHeaders.Names.UPGRADE, HttpHeaders.Values.WEBSOCKET); assertThat(wsrc.isWebSocketRequest(request), is(false)); request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, socketUri); assertThat(wsrc.isWebSocketRequest(request), is(false)); }
From source file:malcolm.HttpUtilTest.java
License:Open Source License
@Test public void getEndpointShouldBeAbsentWhenHostHeaderMissing() { final HttpMessage msg = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/"); when(mockAttribute.get()).thenReturn(false); assertThat(HttpUtil.getEndpoint(msg).isPresent(), is(false)); }
From source file:malcolm.HttpUtilTest.java
License:Open Source License
private HttpRequest httpRequest(final String hostname) { final HttpRequest msg = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/"); msg.headers().add("Host", hostname); return msg;//from w w w .j a v a 2s .c o m }
From source file:me.zhuoran.amoeba.netty.server.HttpServerHandler.java
License:Apache License
protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception { AmoebaHttpRequest request = null;/*w w w. j a va2s . c o m*/ if (msg instanceof HttpRequest) { HttpRequest httpContent = (HttpRequest) msg; if (!httpContent.getDecoderResult().isSuccess()) { sendHttpResponse(ctx, httpContent, new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_REQUEST)); return; } if (httpContent.getMethod() != HttpMethod.GET && httpContent.getMethod() != HttpMethod.POST) { sendHttpResponse(ctx, httpContent, new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.FORBIDDEN)); return; } if (HttpHeaders.is100ContinueExpected(httpContent)) { ctx.write(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CONTINUE)); } String uri = HttpRequestHandler.sanitizeUri(httpContent.getUri()); if (!HttpServer.executorNameList.contains(uri)) { DefaultFullHttpResponse response1 = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.NOT_FOUND); sendHttpResponse(ctx, httpContent, response1); return; } request = new AmoebaHttpRequest(httpContent, ctx.channel().id().asLongText()); } if (msg instanceof HttpContent) { HttpContent httpContent = (HttpContent) msg; ByteBuf content = httpContent.content(); request.setHttpContent(content); request.setContent(content.toString(CharsetUtil.UTF_8)); if (msg instanceof LastHttpContent) { FullHttpResponse response = this.getHttpResponse(request); this.writeResponse(request, response, ctx); } } }
From source file:mousio.etcd4j.requests.EtcdHealthRequest.java
License:Apache License
/** * Constructor/* ww w . j a v a 2 s.com*/ * * @param clientImpl the client to handle this request * @param retryHandler handles retries */ public EtcdHealthRequest(EtcdClientImpl clientImpl, RetryPolicy retryHandler) { super("/health", clientImpl, HttpMethod.GET, retryHandler, EtcdHealthResponse.DECODER); }
From source file:mousio.etcd4j.requests.EtcdMembersRequest.java
License:Apache License
/** * Constructor// w w w.ja v a 2 s . c o m * * @param clientImpl the client to handle this request * @param retryHandler handles retries */ public EtcdMembersRequest(EtcdClientImpl clientImpl, RetryPolicy retryHandler) { super("/v2/members", clientImpl, HttpMethod.GET, retryHandler, EtcdMembersResponse.DECODER); }
From source file:mousio.etcd4j.requests.EtcdSelfStatsRequest.java
License:Apache License
/** * Constructor/*from w w w .j a v a 2s . c o m*/ * * @param clientImpl the client to handle this request * @param retryHandler handles retries */ public EtcdSelfStatsRequest(EtcdClientImpl clientImpl, RetryPolicy retryHandler) { super(clientImpl, HttpMethod.GET, retryHandler, EtcdSelfStatsResponseDecoder.INSTANCE); }
From source file:mousio.etcd4j.requests.EtcdStoreStatsRequest.java
License:Apache License
/** * Constructor/*from w w w .ja va 2 s .c o m*/ * * @param clientImpl the client to handle this request * @param retryHandler handles retries */ public EtcdStoreStatsRequest(EtcdClientImpl clientImpl, RetryPolicy retryHandler) { super(clientImpl, HttpMethod.GET, retryHandler, EtcdStoreStatsResponseDecoder.INSTANCE); }