use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringDecoder in project BRFS by zhangnianli.
the class DiskNettyHttpRequestHandler method requestReceived.
@Override
public void requestReceived(ChannelHandlerContext ctx, FullHttpRequest request) {
LOG.debug("handle request[{}:{}]", request.method(), request.uri());
MessageHandler<DiskMessage> handler = methodToOps.get(request.method());
if (handler == null) {
ResponseSender.sendError(ctx, HttpResponseStatus.METHOD_NOT_ALLOWED);
return;
}
QueryStringDecoder decoder = new QueryStringDecoder(request.uri(), CharsetUtil.UTF_8, true);
DiskMessage message = new DiskMessage();
message.setFilePath(decoder.path());
Map<String, String> params = new HashMap<String, String>();
for (String paramName : decoder.parameters().keySet()) {
params.put(paramName, decoder.parameters().get(paramName).get(0));
}
message.setParams(params);
byte[] data = new byte[request.content().readableBytes()];
request.content().readBytes(data);
message.setData(data);
handler.handle(message, new DefaultHandleResultCallback(ctx));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringDecoder in project BRFS by zhangnianli.
the class StorageNameRequestHandler method requestReceived.
@Override
public void requestReceived(ChannelHandlerContext ctx, FullHttpRequest request) {
LOG.debug("handle request[{}:{}]", request.method(), request.uri());
MessageHandler<StorageNameMessage> handler = handlers.get(request.method().name());
if (handler == null) {
ResponseSender.sendError(ctx, HttpResponseStatus.METHOD_NOT_ALLOWED);
return;
}
QueryStringDecoder decoder = new QueryStringDecoder(request.uri(), CharsetUtil.UTF_8, true);
StorageNameMessage message = new StorageNameMessage();
message.setName(parseName(decoder.path()));
System.out.println("name----" + message.getName());
byte[] data = new byte[request.content().readableBytes()];
request.content().readBytes(data);
// TODO set other properties of StorageNameMessage
handler.handle(message, new DefaultHandleResultCallback(ctx));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringDecoder in project xian by happyyangyuan.
the class IXwwwformurlencodedBody method parseByNettyDecoder.
/**
* parse the http request body using the netty query string decoder.
*/
static JSONObject parseByNettyDecoder(String body) {
JSONObject bodyParameters = new JSONObject();
QueryStringDecoder queryStringDecoder = new QueryStringDecoder(body, false);
Map<String, List<String>> parameters = queryStringDecoder.parameters();
parameters.forEach((key, values) -> {
if (values == null || values.isEmpty()) {
LOG.debug("空参数统一对应空字符串");
bodyParameters.put(key, "");
} else if (values.size() == 1)
bodyParameters.put(key, values.get(0));
else
bodyParameters.put(key, values);
});
return bodyParameters;
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringDecoder in project vertx-web by vert-x3.
the class HttpRequestImpl method queryParams.
@Override
public MultiMap queryParams() {
if (params == null) {
params = new CaseInsensitiveHeaders();
}
if (params.isEmpty()) {
int idx = uri.indexOf('?');
if (idx >= 0) {
QueryStringDecoder dec = new QueryStringDecoder(uri);
dec.parameters().forEach((name, value) -> params.add(name, value));
uri = uri.substring(0, idx);
}
}
return params;
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringDecoder in project cdap by caskdata.
the class MetricQueryParser method parseQueryString.
/**
* From the query string determine the query type, time range and related parameters.
*/
public static void parseQueryString(URI requestURI, MetricDataQueryBuilder builder) throws MetricsPathException {
Map<String, List<String>> queryParams = new QueryStringDecoder(requestURI).parameters();
parseTimeseries(queryParams, builder);
}
Aggregations