Example usage for io.netty.handler.codec.http HttpMethod POST

List of usage examples for io.netty.handler.codec.http HttpMethod POST

Introduction

In this page you can find the example usage for io.netty.handler.codec.http HttpMethod POST.

Prototype

HttpMethod POST

To view the source code for io.netty.handler.codec.http HttpMethod POST.

Click Source Link

Document

The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line.

Usage

From source file:weatherAlarm.endpoints.WeatherAlarmEndpointTest.java

License:Apache License

@Test
public void testNotImplemented() {
    IWeatherAlarmService alarmService = getMockAlarmService();
    WeatherAlarmEndpoint alarmEndpoint = new WeatherAlarmEndpoint();
    alarmEndpoint.setAlarmService(alarmService);

    Capture<byte[]> written = EasyMock.newCapture();
    Capture<HttpResponseStatus> status = EasyMock.newCapture();
    HttpServerRequest<ByteBuf> request = createMockHttpServerRequest(HttpMethod.POST, URI, Observable.empty());
    HttpServerResponse<ByteBuf> response = createMockHttpResponse(status, written);
    alarmEndpoint.handle(request, response);
    HttpResponseStatus expected = HttpResponseStatus.NOT_IMPLEMENTED;
    Assert.assertEquals("Unexpected value for status", expected, status.getValue());
}

From source file:whitespell.net.websockets.socketio.transport.XHRPollingTransport.java

License:Apache License

private void handleMessage(FullHttpRequest req, QueryStringDecoder queryDecoder, ChannelHandlerContext ctx)
        throws IOException {
    String[] parts = queryDecoder.path().split("/");
    if (parts.length > 3) {
        UUID sessionId = UUID.fromString(parts[4]);

        String origin = req.headers().get(HttpHeaders.Names.ORIGIN);
        if (queryDecoder.parameters().containsKey("disconnect")) {
            BaseClient client = sessionId2Client.get(sessionId);
            client.onChannelDisconnect();
            ctx.channel().write(new XHROutMessage(origin, sessionId));
        } else if (HttpMethod.POST.equals(req.getMethod())) {
            onPost(sessionId, ctx, origin, req.content());
        } else if (HttpMethod.GET.equals(req.getMethod())) {
            onGet(sessionId, ctx, origin);
        }/*from ww  w  . j av a  2  s. com*/
    } else {
        log.warn("Wrong {} method request path: {}, from ip: {}. Channel closed!", req.getMethod(), path,
                ctx.channel().remoteAddress());
        ctx.channel().close();
    }
}