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());
}
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();
}
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);
}
}
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"));
}
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();
}
Aggregations