Search in sources :

Example 1 with LineTooLongException

use of com.predic8.membrane.core.transport.http.LineTooLongException in project service-proxy by membrane.

the class HttpUtil method readLine.

public static String readLine(InputStream in) throws IOException, EndOfStreamException {
    StringBuilder line = new StringBuilder(128);
    int b;
    int l = 0;
    while ((b = in.read()) != -1) {
        if (b == 13) {
            in.read();
            return line.toString();
        }
        if (b == 10) {
            in.mark(2);
            if (in.read() != 13)
                in.reset();
            return line.toString();
        }
        line.append((char) b);
        if (++l == MAX_LINE_LENGTH)
            throw new LineTooLongException(line.toString());
    }
    throw new EOFWhileReadingLineException(line.toString());
}
Also used : LineTooLongException(com.predic8.membrane.core.transport.http.LineTooLongException) EOFWhileReadingLineException(com.predic8.membrane.core.transport.http.EOFWhileReadingLineException)

Aggregations

EOFWhileReadingLineException (com.predic8.membrane.core.transport.http.EOFWhileReadingLineException)1 LineTooLongException (com.predic8.membrane.core.transport.http.LineTooLongException)1