Search in sources :

Example 6 with QueryStringDecoder

use of io.netty.handler.codec.http.QueryStringDecoder in project hadoop by apache.

the class TestParameterParser method testDecodePath.

@Test
public void testDecodePath() {
    final String ESCAPED_PATH = "/test%25+1%26%3Dtest?op=OPEN&foo=bar";
    final String EXPECTED_PATH = "/test%+1&=test";
    Configuration conf = new Configuration();
    QueryStringDecoder decoder = new QueryStringDecoder(WebHdfsHandler.WEBHDFS_PREFIX + ESCAPED_PATH);
    ParameterParser testParser = new ParameterParser(decoder, conf);
    Assert.assertEquals(EXPECTED_PATH, testParser.path());
}
Also used : QueryStringDecoder(io.netty.handler.codec.http.QueryStringDecoder) Configuration(org.apache.hadoop.conf.Configuration) Test(org.junit.Test)

Example 7 with QueryStringDecoder

use of io.netty.handler.codec.http.QueryStringDecoder in project moco by dreamhead.

the class DefaultHttpRequest method newRequest.

public static HttpRequest newRequest(final FullHttpRequest request) {
    QueryStringDecoder decoder = new QueryStringDecoder(request.uri());
    ImmutableMap<String, String[]> queries = toQueries(decoder);
    return builder().withVersion(HttpProtocolVersion.versionOf(request.protocolVersion().text())).withHeaders(collectHeaders(request.headers())).withMethod(HttpMethod.valueOf(request.method().toString().toUpperCase())).withUri(decoder.path()).withQueries(queries).withContent(toMessageContent(request)).build();
}
Also used : QueryStringDecoder(io.netty.handler.codec.http.QueryStringDecoder)

Example 8 with QueryStringDecoder

use of io.netty.handler.codec.http.QueryStringDecoder in project netty by netty.

the class Http2RequestHandler method channelRead0.

@Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception {
    QueryStringDecoder queryString = new QueryStringDecoder(request.uri());
    String streamId = streamId(request);
    int latency = toInt(firstValue(queryString, LATENCY_FIELD_NAME), 0);
    if (latency < MIN_LATENCY || latency > MAX_LATENCY) {
        sendBadRequest(ctx, streamId);
        return;
    }
    String x = firstValue(queryString, IMAGE_COORDINATE_X);
    String y = firstValue(queryString, IMAGE_COORDINATE_Y);
    if (x == null || y == null) {
        handlePage(ctx, streamId, latency, request);
    } else {
        handleImage(x, y, ctx, streamId, latency, request);
    }
}
Also used : QueryStringDecoder(io.netty.handler.codec.http.QueryStringDecoder)

Example 9 with QueryStringDecoder

use of io.netty.handler.codec.http.QueryStringDecoder in project riposte by Nike-Inc.

the class RequestInfoTest method getQueryParamSingle_returns_first_item_if_param_value_list_has_multiple_entries.

@Test
public void getQueryParamSingle_returns_first_item_if_param_value_list_has_multiple_entries() {
    // given
    QueryStringDecoder queryParamsMock = mock(QueryStringDecoder.class);
    Map<String, List<String>> params = new HashMap<>();
    params.put("foo", Arrays.asList("bar", "stuff"));
    doReturn(params).when(queryParamsMock).parameters();
    RequestInfo<?> requestInfoSpy = getSpy();
    doReturn(queryParamsMock).when(requestInfoSpy).getQueryParams();
    // when
    String value = requestInfoSpy.getQueryParamSingle("foo");
    // then
    assertThat(value, is("bar"));
}
Also used : QueryStringDecoder(io.netty.handler.codec.http.QueryStringDecoder) HashMap(java.util.HashMap) List(java.util.List) Test(org.junit.Test)

Example 10 with QueryStringDecoder

use of io.netty.handler.codec.http.QueryStringDecoder in project riposte by Nike-Inc.

the class HttpServletRequestWrapperForRequestInfoTest method getQueryString_returns_null_if_no_query_string_exists.

@Test
public void getQueryString_returns_null_if_no_query_string_exists() {
    // given
    QueryStringDecoder queryStringDecoder = new QueryStringDecoder("/some/path");
    doReturn(queryStringDecoder).when(requestInfoMock).getQueryParams();
    // when
    String result = wrapper.getQueryString();
    // then
    assertThat(result).isNull();
}
Also used : QueryStringDecoder(io.netty.handler.codec.http.QueryStringDecoder) Test(org.junit.Test)

Aggregations

QueryStringDecoder (io.netty.handler.codec.http.QueryStringDecoder)28 Test (org.junit.Test)11 List (java.util.List)10 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)5 HttpContent (io.netty.handler.codec.http.HttpContent)5 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)5 HttpRequest (io.netty.handler.codec.http.HttpRequest)4 HashMap (java.util.HashMap)4 DefaultHttpResponse (io.netty.handler.codec.http.DefaultHttpResponse)3 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)3 HttpPostRequestDecoder (io.netty.handler.codec.http.multipart.HttpPostRequestDecoder)3 IOException (java.io.IOException)3 Map (java.util.Map)3 UUID (java.util.UUID)3 ClientHead (com.corundumstudio.socketio.handler.ClientHead)2 ByteBuf (io.netty.buffer.ByteBuf)2 Channel (io.netty.channel.Channel)2 DefaultFullHttpResponse (io.netty.handler.codec.http.DefaultFullHttpResponse)2 DefaultHttpHeaders (io.netty.handler.codec.http.DefaultHttpHeaders)2 HttpResponse (io.netty.handler.codec.http.HttpResponse)2