use of org.apache.flink.shaded.netty4.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();
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringDecoder in project riposte by Nike-Inc.
the class HttpServletRequestWrapperForRequestInfoTest method getQueryString_delegates_to_requestInfo.
@Test
public void getQueryString_delegates_to_requestInfo() {
// given
String queryString = "foo=bar&baz=" + UUID.randomUUID().toString();
QueryStringDecoder queryStringDecoder = new QueryStringDecoder("/some/path?" + queryString);
doReturn(queryStringDecoder).when(requestInfoMock).getQueryParams();
// when
String result = wrapper.getQueryString();
// then
assertThat(result).isEqualTo(queryString);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringDecoder in project BRFS by zhangnianli.
the class HttpParamsDecoder method decodeFromUri.
/**
* 解析Uri中携带的Parameter信息
*
* @param uri
* @return
*/
public static Map<String, String> decodeFromUri(String uri) {
Map<String, String> params = new HashMap<String, String>();
QueryStringDecoder decoder = new QueryStringDecoder(uri, CharsetUtil.UTF_8, true);
Map<String, List<String>> paramMap = decoder.parameters();
for (Map.Entry<String, List<String>> entry : paramMap.entrySet()) {
if (entry.getValue() != null && !entry.getValue().isEmpty()) {
params.put(entry.getKey(), entry.getValue().get(0));
}
}
return params;
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringDecoder in project hadoop by apache.
the class FSImageHandler method channelRead0.
@Override
public void channelRead0(ChannelHandlerContext ctx, HttpRequest request) throws Exception {
if (request.getMethod() != HttpMethod.GET) {
DefaultHttpResponse resp = new DefaultHttpResponse(HTTP_1_1, METHOD_NOT_ALLOWED);
resp.headers().set(CONNECTION, CLOSE);
ctx.write(resp).addListener(ChannelFutureListener.CLOSE);
return;
}
QueryStringDecoder decoder = new QueryStringDecoder(request.getUri());
final String op = getOp(decoder);
final String content;
String path = getPath(decoder);
switch(op) {
case "GETFILESTATUS":
content = image.getFileStatus(path);
break;
case "LISTSTATUS":
content = image.listStatus(path);
break;
case "GETACLSTATUS":
content = image.getAclStatus(path);
break;
case "GETXATTRS":
List<String> names = getXattrNames(decoder);
String encoder = getEncoder(decoder);
content = image.getXAttrs(path, names, encoder);
break;
case "LISTXATTRS":
content = image.listXAttrs(path);
break;
case "GETCONTENTSUMMARY":
content = image.getContentSummary(path);
break;
default:
throw new IllegalArgumentException("Invalid value for webhdfs parameter" + " \"op\"");
}
LOG.info("op=" + op + " target=" + path);
DefaultFullHttpResponse resp = new DefaultFullHttpResponse(HTTP_1_1, HttpResponseStatus.OK, Unpooled.wrappedBuffer(content.getBytes(Charsets.UTF_8)));
resp.headers().set(CONTENT_TYPE, APPLICATION_JSON_UTF8);
resp.headers().set(CONTENT_LENGTH, resp.content().readableBytes());
resp.headers().set(CONNECTION, CLOSE);
ctx.write(resp).addListener(ChannelFutureListener.CLOSE);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringDecoder in project asterixdb by apache.
the class BaseRequest method create.
public static IServletRequest create(FullHttpRequest request) throws IOException {
QueryStringDecoder decoder = new QueryStringDecoder(request.uri());
Map<String, List<String>> param = decoder.parameters();
return new BaseRequest(request, param);
}
Aggregations