/** * request parameters put in {@link #parameters} * * @param req */ private void requestParametersHandler(HttpRequest req) { if (req.method().equals(HttpMethod.POST)) { HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(req); try { List<InterfaceHttpData> postList = decoder.getBodyHttpDatas(); for (InterfaceHttpData data : postList) { List<String> values = new ArrayList<String>(); MixedAttribute value = (MixedAttribute) data; value.setCharset(CharsetUtil.UTF_8); values.add(value.getValue()); this.parameters.put(data.getName(), values); } } catch (Exception e) { logger.error(e.getMessage()); } } }
private void decodePost() { HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(request); // Form Data List<InterfaceHttpData> bodyHttpDatas = decoder.getBodyHttpDatas(); try { for (InterfaceHttpData data : bodyHttpDatas) { if (data.getHttpDataType().equals(HttpDataType.Attribute)) { Attribute attr = (MixedAttribute) data; params.put(data.getName(), new Param(Arrays.asList(attr.getValue()))); } } } catch (IOException e) { throw new RuntimeException(e); } decoder.destroy(); }
private void executePostValues(SeedRequest request,HttpPostRequestDecoder decoder){ List<InterfaceHttpData> params = decoder.getBodyHttpDatas(); for(InterfaceHttpData data :params){ MixedAttribute attribute = (MixedAttribute) data; try { request.setValue(new String(attribute.getName()), URLDecoder.decode(new String(attribute.content().array()),"utf-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } }