java.lang.Object
net.i2p.i2ptunnel.I2PTunnelHTTPClient.InputReader
Enclosing class:
I2PTunnelHTTPClient

private static class I2PTunnelHTTPClient.InputReaderextends Object
Read the first line unbuffered, then subsequent lines. We can't use a BufferedReader for POST because we can't have readahead, since we are passing the stream on to I2PTunnelRunner for the POST data.

Warning - DataHelper limits line length.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) InputStream
    Stream the status line is read from.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Reads the proxy response until the socket closes.
  • Method Summary

    Public Methods
    Modifier and Type
    Method
    Description
    void
    Read the rest of the headers, which keeps firefox from complaining about connection reset after an error on the first line.
    (package private) boolean
    Probe whether the peer closed during a long wait.
    (package private) String
    Reads one CRLF-terminated line.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • InputReader

      public InputReader(InputStream s)
      Reads the proxy response until the socket closes.
      Parameters:
      s - the input stream to wrap
  • Method Details

    • readLine

      String readLine() throws IOException
      Reads one CRLF-terminated line.
      Returns:
      the line without the terminator
      Throws:
      IOException - if the stream fails or ends early
    • peerClosed

      boolean peerClosed(Socket sock)
      Probe whether the peer closed during a long wait. A timed read returns -1 on FIN (peer closed), times out when still open, or yields a pipelined byte which is pushed back so it is not lost.
      Parameters:
      sock - the peer-facing socket (used only for SO_TIMEOUT)
      Returns:
      true if the peer has closed (or the stream is unusable)
    • drain

      public void drain()
      Read the rest of the headers, which keeps firefox from complaining about connection reset after an error on the first line.