throw new ErrorDataDecoderException("Should not be called with the current getStatus"); case HEADERDELIMITER: { if (charsetAttribute != null) { try { localCharset = Charset.forName(charsetAttribute.getValue()); } catch (IOException e) { throw new ErrorDataDecoderException(e); } catch (UnsupportedCharsetException e) { throw new ErrorDataDecoderException(e); try { size = lengthAttribute != null? Long.parseLong(lengthAttribute .getValue()) : 0L; } catch (IOException e) { throw new ErrorDataDecoderException(e); currentAttribute = factory.createAttribute(request, cleanString(nameAttribute.getValue()), size); } else { currentAttribute = factory.createAttribute(request, cleanString(nameAttribute.getValue())); currentAttribute.setCharset(localCharset);
try { String key = encodeAttribute(attribute.getName(), charset); String value = encodeAttribute(attribute.getValue(), charset); Attribute newattribute = factory.createAttribute(request, key, value); multipartHttpDatas.add(newattribute); globalBodySize += newattribute.getName().length() + 1 + newattribute.length() + 1; } catch (IOException e) { throw new ErrorDataEncoderException(e); Attribute newattribute = factory.createAttribute(request, key, value); multipartHttpDatas.add(newattribute); globalBodySize += newattribute.getName().length() + 1 + newattribute.length() + 1; + HttpHeaderValues.NAME + "=\"" + attribute.getName() + "\"\r\n"); attribute.length() + "\r\n"); Charset localcharset = attribute.getCharset(); if (localcharset != null) { multipartHttpDatas.add(internal); multipartHttpDatas.add(data); globalBodySize += attribute.length() + internal.size(); } else if (data instanceof FileUpload) { FileUpload fileUpload = (FileUpload) data;
@Override public void parse() throws Exception { LOG.trace("CommandName: " + COMMAND_NAME + ": Parse.."); HttpDataFactory factory = new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE); HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(factory, getRequest()); if (decoder.isMultipart()) { Attribute attribute = (Attribute) data; if (CommonEpConstans.REQUEST_SIGNATURE_ATTR_NAME.equals(data.getName())) { requestSignature = attribute.get(); if (LOG.isTraceEnabled()) { LOG.trace("Multipart name " + data.getName() + " type " requestKey = attribute.get(); if (LOG.isTraceEnabled()) { LOG.trace("Multipart name " + data.getName() + " type " requestData = attribute.get(); if (LOG.isTraceEnabled()) { LOG.trace("Multipart name " + data.getName() + " type " nextProtocol = ByteBuffer.wrap(attribute.get()).getInt(); LOG.trace("[{}] next protocol is {}", getSessionUuid(), nextProtocol);
@Override public void setContent(InputStream inputStream) throws IOException { if (attribute instanceof MemoryAttribute) { // change to Disk even if we don't know the size attribute = new DiskAttribute(attribute.getName(), attribute.definedLength()); attribute.setMaxSize(maxSize); } attribute.setContent(inputStream); }
private void parseAttribute(Attribute attribute) throws IOException { var name = attribute.getName(); var value = attribute.getValue(); List<String> values; if (this.parameters.containsKey(name)) { values = this.parameters.get(name); values.add(value); } else { values = new ArrayList<>(); values.add(value); this.parameters.put(name, values); } }
@Override public void addContent(ByteBuf buffer, boolean last) throws IOException { if (attribute instanceof MemoryAttribute) { checkSize(attribute.length() + buffer.readableBytes()); if (attribute.length() + buffer.readableBytes() > limitSize) { DiskAttribute diskAttribute = new DiskAttribute(attribute .getName(), attribute.definedLength()); diskAttribute.setMaxSize(maxSize); if (((MemoryAttribute) attribute).getByteBuf() != null) { diskAttribute.addContent(((MemoryAttribute) attribute) .getByteBuf(), false); } attribute = diskAttribute; } } attribute.addContent(buffer, last); }
String code; try { code = encoding.getValue().toLowerCase(); } catch (IOException e) { throw new ErrorDataDecoderException(e); if (charsetAttribute != null) { try { localCharset = Charset.forName(charsetAttribute.getValue()); } catch (IOException e) { throw new ErrorDataDecoderException(e); } catch (UnsupportedCharsetException e) { throw new ErrorDataDecoderException(e); long size; try { size = lengthAttribute != null ? Long.parseLong(lengthAttribute.getValue()) : 0L; } catch (IOException e) { throw new ErrorDataDecoderException(e); String contentType; if (contentTypeAttribute != null) { contentType = contentTypeAttribute.getValue(); } else { contentType = HttpPostBodyUtil.DEFAULT_BINARY_CONTENT_TYPE; currentFileUpload = factory.createFileUpload(request, cleanString(nameAttribute.getValue()), cleanString(filenameAttribute.getValue()), contentType, mechanism.value(), localCharset,
int readerIndex = undecodedChunk.readerIndex(); if (currentStatus == MultiPartStatus.DISPOSITION) { currentFieldAttributes = new TreeMap<CharSequence, Attribute>(CaseIgnoringComparator.INSTANCE); newline = readLine(undecodedChunk, charset); } catch (NotEnoughDataDecoderException ignored) { undecodedChunk.readerIndex(readerIndex); return null; attribute = getContentDispositionAttribute(values); } catch (NullPointerException e) { throw new ErrorDataDecoderException(e); } catch (IllegalArgumentException e) { throw new ErrorDataDecoderException(e); currentFieldAttributes.put(attribute.getName(), attribute); Attribute attribute; try { attribute = factory.createAttribute(request, HttpHeaderNames.CONTENT_LENGTH.toString(), cleanString(contents[1])); } catch (NullPointerException e) { Attribute attribute; try { attribute = factory.createAttribute(request, charsetHeader, cleanString(values)); currentFieldAttributes.put(attribute.getName(), attribute);
String content = ((FullHttpRequest) request).content().toString(CharsetUtil.UTF_8); JSONObject object = JSON.parseObject(content); if (object != null) { if (data.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute) { Attribute attribute = (Attribute) data; params.add(new FormParam(attribute.getName(), attribute.getValue()));
@Override public String getValue() throws IOException { return attribute.getValue(); }
if (httpDataAttributes == null) { final HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(new DefaultHttpDataFactory(false), request); final Map<String, List<String>> map = new HashMap<String, List<String>>(); Attribute attribute = (Attribute) data; List<String> list = map.get(attribute.getName()); if (list == null) { list = new LinkedList<String>(); map.put(attribute.getName(), list); list.add(attribute.getValue());
@Override public String getName() { return attribute.getName(); }
HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(new DefaultHttpDataFactory(false), request); try{ List<InterfaceHttpData> postList = decoder.getBodyHttpDatas(); if (InterfaceHttpData.HttpDataType.Attribute == data.getHttpDataType()) { Attribute attribute = (Attribute) data; attribute.setCharset(charset); String value = attribute.getValue(); List<String> valueList = requestParamsMap.get(name); if(null == valueList) {
byte[] buf = new byte[200]; ... DefaultFullHttpRequest req = new DefaultFullHttpRequest(httpVersion, HttpMethod.POST, uri); DefaultHttpDataFactory factory = new DefaultHttpDataFactory(); HttpPostRequestEncoder enc = new HttpPostRequestEncoder(factory, req, false, CharsetUtil.UTF_8, HttpPostRequestEncoder.EncoderMode.RFC1738); Attribute attr = factory.createAttribute(req, "someBinaryVar"); attr.setContent(io.netty.buffer.Unpooled.wrappedBuffer(buf)); enc.addBodyHttpData(attr); ... enc.finalizeRequest();
@Override public void setCharset(Charset charset) { attribute.setCharset(charset); }
@Override public byte[] get() throws IOException { return attribute.get(); }
String code; try { code = encoding.getValue().toLowerCase(); } catch (IOException e) { throw new ErrorDataDecoderException(e); if (charsetAttribute != null) { try { localCharset = Charset.forName(charsetAttribute.getValue()); } catch (IOException e) { throw new ErrorDataDecoderException(e); } catch (UnsupportedCharsetException e) { throw new ErrorDataDecoderException(e); long size; try { size = lengthAttribute != null ? Long.parseLong(lengthAttribute.getValue()) : 0L; } catch (IOException e) { throw new ErrorDataDecoderException(e); String contentType; if (contentTypeAttribute != null) { contentType = contentTypeAttribute.getValue(); } else { contentType = HttpPostBodyUtil.DEFAULT_BINARY_CONTENT_TYPE; currentFileUpload = factory.createFileUpload(request, cleanString(nameAttribute.getValue()), cleanString(filenameAttribute.getValue()), contentType, mechanism.value(), localCharset,
@Override public void setContent(File file) throws IOException { checkSize(file.length()); if (file.length() > limitSize) { if (attribute instanceof MemoryAttribute) { // change to Disk attribute = new DiskAttribute(attribute.getName(), attribute.definedLength()); attribute.setMaxSize(maxSize); } } attribute.setContent(file); }
@Override public void addContent(ByteBuf buffer, boolean last) throws IOException { if (attribute instanceof MemoryAttribute) { checkSize(attribute.length() + buffer.readableBytes()); if (attribute.length() + buffer.readableBytes() > limitSize) { DiskAttribute diskAttribute = new DiskAttribute(attribute .getName(), attribute.definedLength()); diskAttribute.setMaxSize(maxSize); if (((MemoryAttribute) attribute).getByteBuf() != null) { diskAttribute.addContent(((MemoryAttribute) attribute) .getByteBuf(), false); } attribute = diskAttribute; } } attribute.addContent(buffer, last); }