Java 类io.netty.handler.codec.http.multipart.MixedAttribute 实例源码

项目:netty-restful-server    文件:ApiProtocol.java   
/**
 * 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());
        }
    }
}
项目:netty-restful-server    文件:ApiProtocol.java   
/**
 * 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());
        }
    }
}
项目:locomotive    文件:LocomotiveRequestWrapper.java   
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();
}
项目:Seed    文件:SeedHttpHandler.java   
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();
        }
    }
}