use of io.netty.handler.codec.http.multipart.MixedAttribute 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);
}
Aggregations