Interface HttpConnectionBuilder


public interface HttpConnectionBuilder
Configures an HttpConnection. The connection can be created after construction.
Author:
Stephan Fuhrmann
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Constructs a connection from this builder.
    void
    setConnectTimeout(int timeout)
    Configures the timeout for connecting to the server.
    void
    setProxy(URL proxy)
    Sets the HTTP/HTTPS proxy to use.
    void
    setReadTimeout(int timeout)
    Configures the timeout for reading from the server.
    void
    Adds an HTTP request header field to the request.
  • Method Details

    • setConnectTimeout

      void setConnectTimeout(int timeout)
      Configures the timeout for connecting to the server.
      Parameters:
      timeout - the timeout in milliseconds.
    • setReadTimeout

      void setReadTimeout(int timeout)
      Configures the timeout for reading from the server.
      Parameters:
      timeout - the timeout in milliseconds.
    • setRequestProperty

      void setRequestProperty(String key, String value)
      Adds an HTTP request header field to the request.
      Parameters:
      key - the header field name, for example "User-Agent".
      value - the header field value.
    • setProxy

      void setProxy(URL proxy)
      Sets the HTTP/HTTPS proxy to use.
      Parameters:
      proxy - the URL of the proxy to use.
    • build

      HttpConnection build() throws IOException
      Constructs a connection from this builder. The connection is usually being opened by this method.
      Returns:
      an open HTTP connection.
      Throws:
      IOException - if building the connection with the given parameters failed.