Package io.netty.handler.codec.http.multipart

Examples of io.netty.handler.codec.http.multipart.InterfaceHttpData


     * Example of reading request by chunk and getting values from chunk to chunk
     */
    private void readHttpDataChunkByChunk() {
        try {
            while (decoder.hasNext()) {
                InterfaceHttpData data = decoder.next();
                if (data != null) {
                    // new value
                    writeHttpData(data);
                }
            }
View Full Code Here


     * Example of reading request by chunk and getting values from chunk to chunk
     */
    private void readHttpDataChunkByChunk() {
        try {
            while (decoder.hasNext()) {
                InterfaceHttpData data = decoder.next();
                if (data != null) {
                    try {
                        // new value
                        writeHttpData(data);
                    } finally {
                        data.release();
                    }
                }
            }
        } catch (EndOfDataDecoderException e1) {
            // end
View Full Code Here

    Map<String, List<String>> attributes = new LinkedHashMap<>();
    Map<String, List<UploadedFile>> files = new LinkedHashMap<>();

    try {
      InterfaceHttpData data = decoder.next();
      while (data != null) {
        if (data.getHttpDataType().equals(InterfaceHttpData.HttpDataType.Attribute)) {
          List<String> values = attributes.get(data.getName());
          if (values == null) {
            values = new ArrayList<>(1);
            attributes.put(data.getName(), values);
          }
          try {
            values.add(((Attribute) data).getValue());
          } catch (IOException e) {
            throw uncheck(e);
          } finally {
            data.release();
          }
        } else if (data.getHttpDataType().equals(InterfaceHttpData.HttpDataType.FileUpload)) {
          List<UploadedFile> values = files.get(data.getName());
          if (values == null) {
            values = new ArrayList<>(1);
            files.put(data.getName(), values);
          }
          try {
            FileUpload nettyFileUpload = (FileUpload) data;
            final ByteBuf byteBuf = nettyFileUpload.getByteBuf();
            byteBuf.retain();
            context.onClose(new Action<RequestOutcome>() {
              @Override
              public void execute(RequestOutcome thing) throws Exception {
                byteBuf.release();
              }
            });

            MediaType contentType;
            String rawContentType = nettyFileUpload.getContentType();
            if (rawContentType == null) {
              contentType = null;
            } else {
              Charset charset = nettyFileUpload.getCharset();
              if (charset == null) {
                contentType = DefaultMediaType.get(rawContentType);
              } else {
                contentType = DefaultMediaType.get(rawContentType + ";charset=" + charset);
              }
            }

            UploadedFile fileUpload = new DefaultUploadedFile(new ByteBufBackedTypedData(byteBuf, contentType), nettyFileUpload.getFilename());

            values.add(fileUpload);
          } catch (IOException e) {
            throw uncheck(e);
          } finally {
            data.release();
          }
        }
        data = decoder.next();
      }
    } catch (HttpPostRequestDecoder.EndOfDataDecoderException ignore) {
View Full Code Here

     * Example of reading request by chunk and getting values from chunk to chunk
     */
    private void readHttpDataChunkByChunk() {
        try {
            while (decoder.hasNext()) {
                InterfaceHttpData data = decoder.next();
                if (data != null) {
                    try {
                        // new value
                        writeHttpData(data);
                    } finally {
                        data.release();
                    }
                }
            }
        } catch (EndOfDataDecoderException e1) {
            // end
View Full Code Here

  synchronized void handleEnd() {
    if (decoder != null) {
      try {
        decoder.offer(LastHttpContent.EMPTY_LAST_CONTENT);
        while (decoder.hasNext()) {
          InterfaceHttpData data = decoder.next();
          if (data instanceof Attribute) {
            Attribute attr = (Attribute) data;
            try {
              if (isURLEncoded) {
                attributes().add(urlDecode(attr.getName()), urlDecode(attr.getValue()));
View Full Code Here

     * Example of reading request by chunk and getting values from chunk to chunk
     */
    private void readHttpDataChunkByChunk() {
        try {
            while (decoder.hasNext()) {
                InterfaceHttpData data = decoder.next();
                if (data != null) {
                    try {
                        // new value
                        writeHttpData(data);
                    } finally {
                        data.release();
                    }
                }
            }
        } catch (EndOfDataDecoderException e1) {
            // end
View Full Code Here

     * Example of reading request by chunk and getting values from chunk to chunk
     */
    private void readHttpDataChunkByChunk() {
        try {
            while (decoder.hasNext()) {
                InterfaceHttpData data = decoder.next();
                if (data != null) {
                    try {
                        // new value
                        writeHttpData(data);
                    } finally {
                        data.release();
                    }
                }
            }
        } catch (EndOfDataDecoderException e1) {
            // end
View Full Code Here

TOP

Related Classes of io.netty.handler.codec.http.multipart.InterfaceHttpData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.