Package org.jboss.as.domain.http.server.multipart

Examples of org.jboss.as.domain.http.server.multipart.MultipartHeader


            // Read from the stream until the deployment is found in the POST data.
            while (!isDeploymentPart && !iStream.isOuterStreamClosed()) {
                int numRead = 0;

                // Read the POST section header from the inner stream.
                final MultipartHeader header = readHeader(iStream);

                if(header != null) {
                    // Determine if the current section is a deployment file upload.
                    isDeploymentPart = MULTIPART_FORM_DATA_CONTENT_TYPE.equals(header.getContentType());

                    /*
                     *  Read the body following the header.  If it is the deployment,
                     *  write it to the temporary file.  Otherwise, discard the data.
                     */
 
View Full Code Here


     * @param boundaryStream A <code>BoundaryDelimitedInputStream</code> that wraps a POST request.
     * @return A <code>MultipartHeader</code> object wrapping the extracted header or <code>null</code> if the stream is closed.
     * @throws IOException if an error occurs while attempting to read the headers from the current inside stream.
     */
    private MultipartHeader readHeader(final BoundaryDelimitedInputStream boundaryStream) throws IOException {
        MultipartHeader currentHeader = null;
        if (!boundaryStream.isOuterStreamClosed()) {
            int separatorCounter = 0;
            byte[] separatorBuffer = new byte[POST_HEADER_BOUNDARY.length];
            final ByteArrayOutputStream bos = new ByteArrayOutputStream();

            try {
                // Read the header until the post header separator sequence is found.
                while (separatorCounter < POST_HEADER_BOUNDARY.length) {
                    int current = boundaryStream.read();
                    if (current == POST_HEADER_BOUNDARY[separatorCounter]) {
                        separatorBuffer[separatorCounter] = (byte) current;
                        separatorCounter++;
                    } else {
                        if (separatorCounter > 0) {
                            bos.write(separatorBuffer, 0, separatorCounter);
                        }
                        bos.write(current);
                        separatorCounter = 0;
                    }
                }
            } finally {
                bos.flush();
                bos.close();
            }

            // Create the header from the read data
            currentHeader = new MultipartHeader(bos.toByteArray());
        }

        return currentHeader;
    }
View Full Code Here

            // Read from the stream until the deployment is found in the POST data.
            while (!isDeploymentPart && !iStream.isOuterStreamClosed()) {
                int numRead = 0;

                // Read the POST section header from the inner stream.
                final MultipartHeader header = readHeader(iStream);

                if(header != null) {
                    // Determine if the current section is a deployment file upload.
                    isDeploymentPart = MULTIPART_FORM_DATA_CONTENT_TYPE.equals(header.getContentType());

                    /*
                     *  Read the body following the header.  If it is the deployment,
                     *  write it to the temporary file.  Otherwise, discard the data.
                     */
 
View Full Code Here

     * @param boundaryStream A <code>BoundaryDelimitedInputStream</code> that wraps a POST request.
     * @return A <code>MultipartHeader</code> object wrapping the extracted header or <code>null</code> if the stream is closed.
     * @throws IOException if an error occurs while attempting to read the headers from the current inside stream.
     */
    private MultipartHeader readHeader(final BoundaryDelimitedInputStream boundaryStream) throws IOException {
        MultipartHeader currentHeader = null;
        if (!boundaryStream.isOuterStreamClosed()) {
            int separatorCounter = 0;
            byte[] separatorBuffer = new byte[POST_HEADER_BOUNDARY.length];
            final ByteArrayOutputStream bos = new ByteArrayOutputStream();

            try {
                // Read the header until the post header separator sequence is found.
                while (separatorCounter < POST_HEADER_BOUNDARY.length) {
                    int current = boundaryStream.read();
                    if (current == POST_HEADER_BOUNDARY[separatorCounter]) {
                        separatorBuffer[separatorCounter] = (byte) current;
                        separatorCounter++;
                    } else {
                        if (separatorCounter > 0) {
                            bos.write(separatorBuffer, 0, separatorCounter);
                        }
                        bos.write(current);
                        separatorCounter = 0;
                    }
                }
            } finally {
                bos.flush();
                bos.close();
            }

            // Create the header from the read data
            currentHeader = new MultipartHeader(bos.toByteArray());
        }

        return currentHeader;
    }
View Full Code Here

TOP

Related Classes of org.jboss.as.domain.http.server.multipart.MultipartHeader

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.