microsoft-azure-storage/src/com/microsoft/azure/storage/table/MimeHelper.java
private static MimePart readMimePart(final BufferedReader reader, final String boundary,
            final OperationContext opContext) throws IOException, StorageException {
        final MimePart retPart = new MimePart();
        // Read HttpStatus code
        String tempStr = getNextLineSkippingBlankLines(reader);
        if (!tempStr.startsWith("HTTP/1.1 ")) {
            throw generateMimeParseException();
        }

        final String[] headerVals = tempStr.split(" ");

        if (headerVals.length < 3) {
            throw generateMimeParseException();
        }

        retPart.httpStatusCode = Integer.parseInt(headerVals[1]);
        // "HTTP/1.1 XXX ".length() => 13
        retPart.httpStatusMessage = tempStr.substring(13);

        // Read headers
        tempStr = reader.readLine();
        while (tempStr != null && tempStr.length() > 0) {
            final String[] headerParts = tempStr.split(": ");
            if (headerParts.length < 2) {
                throw generateMimeParseException();
            }

            retPart.headers.put(headerParts[0], headerParts[1]);
            tempStr = reader.readLine();
        }

        // Store json payload
        reader.mark(1024 * 1024);
        tempStr = getNextLineSkippingBlankLines(reader);

        if (tempStr == null) {
            throw generateMimeParseException();
        }

        // empty body
        if (tempStr.startsWith(boundary)) {
            reader.reset();
            retPart.payload = Constants.EMPTY_STRING;
            return retPart;
        }
        final StringBuilder payloadBuilder = new StringBuilder();
        // read until mime closure or end of file
        while (!tempStr.startsWith(boundary)) {
            payloadBuilder.append(tempStr);
            reader.mark(1024 * 1024);
            tempStr = getNextLineSkippingBlankLines(reader);
            if (tempStr == null) {
                throw generateMimeParseException();
            }
        }

        // positions stream at start of next MIME Header
        reader.reset();

        retPart.payload = payloadBuilder.toString();

        return retPart;
    }
private static MimePart readMimePart(final BufferedReader reader, final String boundary,
            final OperationContext opContext) throws IOException, StorageException {
        final MimePart retPart = new MimePart();
        // Read HttpStatus code
        String tempStr = getNextLineSkippingBlankLines(reader);
        if (!tempStr.startsWith("HTTP/1.1 ")) {
            throw generateMimeParseException();
        }

        final String[] headerVals = tempStr.split(" ");

        if (headerVals.length < 3) {
            throw generateMimeParseException();
        }

        retPart.httpStatusCode = Integer.parseInt(headerVals[1]);
        // "HTTP/1.1 XXX ".length() => 13
        retPart.httpStatusMessage = tempStr.substring(13);

        // Read headers
        tempStr = reader.readLine();
        while (tempStr != null && tempStr.length() > 0) {
            final String[] headerParts = tempStr.split(": ");
            if (headerParts.length < 2) {
                throw generateMimeParseException();
            }

            retPart.headers.put(headerParts[0], headerParts[1]);
            tempStr = reader.readLine();
        }

        // Store json payload
        reader.mark(1024 * 1024);
        tempStr = getNextLineSkippingBlankLines(reader);

        if (tempStr == null) {
            throw generateMimeParseException();
        }

        // empty body
        if (tempStr.startsWith(boundary)) {
            reader.reset();
            retPart.payload = Constants.EMPTY_STRING;
            return retPart;
        }
        final StringBuilder payloadBuilder = new StringBuilder();
        // read until mime closure or end of file
        while (!tempStr.startsWith(boundary)) {
            payloadBuilder.append(tempStr);
            reader.mark(1024 * 1024);
            tempStr = getNextLineSkippingBlankLines(reader);
            if (tempStr == null) {
                throw generateMimeParseException();
            }
        }

        // positions stream at start of next MIME Header
        reader.reset();

        retPart.payload = payloadBuilder.toString();

        return retPart;
    }
private static MimePart readMimePart ( final BufferedReader reader , final String boundary , final OperationContext opContext ) throws IOException , StorageException { final MimePart retPart = new MimePart ( ) ; // Read HttpStatus code String tempStr = getNextLineSkippingBlankLines ( reader ) ; if ( ! tempStr . startsWith ( "HTTP/1.1 " ) ) { throw generateMimeParseException ( ) ; } final String [ ] headerVals = tempStr . split ( " " ) ; if ( headerVals . length < 3 ) { throw generateMimeParseException ( ) ; } retPart . httpStatusCode = Integer . parseInt ( headerVals [ 1 ] ) ; // "HTTP/1.1 XXX ".length() => 13 retPart . httpStatusMessage = tempStr . substring ( 13 ) ; // Read headers tempStr = reader . readLine ( ) ; while ( tempStr != null && tempStr . length ( ) > 0 ) { final String [ ] headerParts = tempStr . split ( ": " ) ; if ( headerParts . length < 2 ) { throw generateMimeParseException ( ) ; } retPart . headers . put ( headerParts [ 0 ] , headerParts [ 1 ] ) ; tempStr = reader . readLine ( ) ; } // Store json payload reader . mark ( 1024 * 1024 ) ; tempStr = getNextLineSkippingBlankLines ( reader ) ; if ( tempStr == null ) { throw generateMimeParseException ( ) ; } // empty body if ( tempStr . startsWith ( boundary ) ) { reader . reset ( ) ; retPart . payload = Constants . EMPTY_STRING ; return retPart ; } final StringBuilder payloadBuilder = new StringBuilder ( ) ; // read until mime closure or end of file while ( ! tempStr . startsWith ( boundary ) ) { payloadBuilder . append ( tempStr ) ; reader . mark ( 1024 * 1024 ) ; tempStr = getNextLineSkippingBlankLines ( reader ) ; if ( tempStr == null ) { throw generateMimeParseException ( ) ; } } // positions stream at start of next MIME Header reader . reset ( ) ; retPart . payload = payloadBuilder . toString ( ) ; return retPart ; }
Reserved for internal use. A static factory method that generates a {@link MimePart} containing the next MIME
part read from the {@link BufferedReader}.
The {@link BufferedReader} is left positioned at the start of the next MIME boundary header.

@param reader
The {@link BufferedReader} containing the response stream to parse.
@param boundary
A <code>String</code> containing the MIME part boundary string.
An {@link OperationContext} object for tracking the current operation. Specify <code>null</code> to
safely ignore operation context.
@return
A {@link MimePart} constructed by parsing the next MIME part data from the {@link BufferedReader}.
@throws IOException
if an error occured accessing the input stream.
@throws StorageException
if an error occured parsing the input stream.
Reserved for internal use . A static factory method that generates a { @link MimePart } containing the next MIME part read from the { @link BufferedReader } . The { @link BufferedReader } is left positioned at the start of the next MIME boundary header .