java.lang.Object
net.i2p.sam.ReadLine
Modified from I2PTunnelHTTPServer Handles UTF-8. Does not buffer past the end of line.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classThrown when a client line exceeds the limit.Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intLongest line accepted from the client: 8 KB.Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionstatic voidreadLine(Socket socket, StringBuilder buf, int timeout) Read a line terminated by newline, with a total read timeout.
Field Details
MAX_LINE_LENGTH
private static final int MAX_LINE_LENGTHLongest line accepted from the client: 8 KB.- See Also:
Constructor Details
ReadLine
private ReadLine()Creates a new ReadLine instance (utility class).
Method Details
readLine
Read a line terminated by newline, with a total read timeout.Warning - strips \n but not \r Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded.
- Parameters:
socket- the socket to read from, whose SO_TIMEOUT this sets to the remaining timebuf- the buffer the line is appended to, without its newlinetimeout- forever if if zero or negative- Throws:
SocketTimeoutException- if timeout is reached before newlineEOFException- if EOF is reached before newlineReadLine.LineTooLongException- if too longIOException- on other errors in the underlying stream