use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringDecoder in project java-chassis by ServiceComb.
the class CseClientHttpRequest method execute.
@Override
public ClientHttpResponse execute() throws IOException {
RequestMeta requestMeta = createRequestMeta(method.name(), uri);
QueryStringDecoder queryStringDecoder = new QueryStringDecoder(uri.getRawSchemeSpecificPart());
Map<String, List<String>> queryParams = queryStringDecoder.parameters();
Object[] args = this.collectArguments(requestMeta, queryParams);
// 异常流程,直接抛异常出去
return this.invoke(requestMeta, args);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringDecoder in project asterixdb by apache.
the class PostRequest method create.
public static IServletRequest create(FullHttpRequest request) throws IOException {
List<String> names = new ArrayList<>();
List<String> values = new ArrayList<>();
HttpPostRequestDecoder decoder = null;
try {
decoder = new HttpPostRequestDecoder(request);
} catch (Exception e) {
//ignore. this means that the body of the POST request does not have key value pairs
LOGGER.log(Level.WARNING, "Failed to decode a post message. Fix the API not to have queries as POST body", e);
}
if (decoder != null) {
try {
List<InterfaceHttpData> bodyHttpDatas = decoder.getBodyHttpDatas();
for (InterfaceHttpData data : bodyHttpDatas) {
if (data.getHttpDataType().equals(InterfaceHttpData.HttpDataType.Attribute)) {
Attribute attr = (MixedAttribute) data;
names.add(data.getName());
values.add(attr.getValue());
}
}
} finally {
decoder.destroy();
}
}
return new PostRequest(request, new QueryStringDecoder(request.uri()).parameters(), names, values);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringDecoder in project BRFS by zhangnianli.
the class DataRequestHandler method requestReceived.
@Override
public void requestReceived(ChannelHandlerContext ctx, FullHttpRequest request) {
LOG.debug("handle request[{}:{}]", request.method(), request.uri());
MessageHandler<DataMessage> 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);
DataMessage message = new DataMessage();
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 dubbo by alibaba.
the class HttpCommandDecoder method decode.
public static CommandContext decode(HttpRequest request) {
CommandContext commandContext = null;
if (request != null) {
QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri());
String path = queryStringDecoder.path();
String[] array = path.split("/");
if (array.length == 2) {
String name = array[1];
// process GET request and POST request separately. Check url for GET, and check body for POST
if (request.getMethod() == HttpMethod.GET) {
if (queryStringDecoder.parameters().isEmpty()) {
commandContext = CommandContextFactory.newInstance(name);
commandContext.setHttp(true);
} else {
List<String> valueList = new ArrayList<String>();
for (List<String> values : queryStringDecoder.parameters().values()) {
valueList.addAll(values);
}
commandContext = CommandContextFactory.newInstance(name, valueList.toArray(new String[] {}), true);
}
} else if (request.getMethod() == HttpMethod.POST) {
HttpPostRequestDecoder httpPostRequestDecoder = new HttpPostRequestDecoder(request);
List<String> valueList = new ArrayList<String>();
for (InterfaceHttpData interfaceHttpData : httpPostRequestDecoder.getBodyHttpDatas()) {
if (interfaceHttpData.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute) {
Attribute attribute = (Attribute) interfaceHttpData;
try {
valueList.add(attribute.getValue());
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
}
if (valueList.isEmpty()) {
commandContext = CommandContextFactory.newInstance(name);
commandContext.setHttp(true);
} else {
commandContext = CommandContextFactory.newInstance(name, valueList.toArray(new String[] {}), true);
}
}
}
}
return commandContext;
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.QueryStringDecoder in project wso2-synapse by wso2.
the class HttpRequestInformationProcessor method populateQueryParameters.
private void populateQueryParameters(HttpRequest request, HttpRequestContext requestContext) {
QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri());
Map<String, List<String>> params = queryStringDecoder.parameters();
requestContext.setQueryParameters(params);
}
Aggregations