public boolean readHeaders() { int headerSize = 5; int headergrow = 2; headers = new Header[headerSize]; headerPos = 0; if (peekByte() < 0) { return false; } Header h = getHeader(); while (h != null) { if (headerPos == headerSize) { Header newheaders[] = new Header[headerSize + headergrow]; System.arraycopy(headers, 0, newheaders, 0, headerSize); headers = newheaders; headerSize += headergrow; } headers[headerPos++] = h; h = getHeader(); } return true; }
public MIMEReader(InputStream stream, String boundary) { this.stream = stream; this.boundary = boundary; separator = "--" + boundary; lastsep = separator + "--"; if (separator == null) { throw new NullPointerException(); } String line = getLine(); if (!separator.equals(line)) { throw new XProcException("MIME multipart doesn't start with separator?"); } }
public String getLine() { String line = ""; boolean done = false; while (!done) { int b = nextByte(); int peek = peekByte(); if (b == '\r') { if (peek == '\n') { b = nextByte(); peek = peekByte(); } else { b = '\n'; } } if (b < 0) { throw new XProcException("Got -1 reading stream..."); } if (b == '\n') { done = true; } else { line += (char) b; } } return line; }
private void readMultipartContent(TreeWriter tree, InputStream bodyStream, String boundary) throws IOException, SaxonApiException { MIMEReader reader = new MIMEReader(bodyStream, boundary); boolean done = false; while (reader.readHeaders()) { Header pctype = reader.getHeader("Content-Type"); Header pclen = reader.getHeader("Content-Length"); partStream = reader.readBodyPart(len); } else { partStream = reader.readBodyPart();
private void readMultipartContent(TreeWriter tree, InputStream bodyStream, String boundary) throws IOException, SaxonApiException { MIMEReader reader = new MIMEReader(bodyStream, boundary); boolean done = false; while (reader.readHeaders()) { Header pctype = reader.getHeader("Content-Type"); Header pclen = reader.getHeader("Content-Length"); partStream = reader.readBodyPart(len); } else { partStream = reader.readBodyPart();
public String getLine() { String line = ""; boolean done = false; while (!done) { int b = nextByte(); int peek = peekByte(); if (b == '\r') { if (peek == '\n') { b = nextByte(); peek = peekByte(); } else { b = '\n'; } } if (b < 0) { throw new XProcException("Got -1 reading stream..."); } if (b == '\n') { done = true; } else { line += (char) b; } } return line; }
public boolean readHeaders() { int headerSize = 5; int headergrow = 2; headers = new Header[headerSize]; headerPos = 0; if (peekByte() < 0) { return false; } Header h = getHeader(); while (h != null) { if (headerPos == headerSize) { Header newheaders[] = new Header[headerSize + headergrow]; System.arraycopy(headers, 0, newheaders, 0, headerSize); headers = newheaders; headerSize += headergrow; } headers[headerPos++] = h; h = getHeader(); } return true; }
public MIMEReader(InputStream stream, String boundary) { this.stream = stream; this.boundary = boundary; separator = "--" + boundary; lastsep = separator + "--"; if (separator == null) { throw new NullPointerException(); } String line = getLine(); if (!separator.equals(line)) { throw new XProcException("MIME multipart doesn't start with separator?"); } }
int state = B_SOL; while (!done) { int b = nextByte(); if (b < 0) { throw new XProcException("Got -1 in readBodyPart?"); if (b == '-') { state = B_MATCHLAST; nextByte(); } else if (b == '\r' || b == '\n') { done = true; bodyidx -= (separator.length() + 3); // The CR/LF is part of the separator! if (b == '\r' && peekByte() == '\n') { nextByte(); if (b == '\r' && peekByte() == '\n') { nextByte();
int state = B_SOL; while (!done) { int b = nextByte(); if (b < 0) { throw new XProcException("Got -1 in readBodyPart?"); if (b == '-') { state = B_MATCHLAST; nextByte(); } else if (b == '\r' || b == '\n') { done = true; bodyidx -= (separator.length() + 3); // The CR/LF is part of the separator! if (b == '\r' && peekByte() == '\n') { nextByte(); if (b == '\r' && peekByte() == '\n') { nextByte();