JavaScript is disabled on your browser.
gnu.inet.http

Class HTTPConnection



  • public class HTTPConnection
    extends java.lang.Object
    A connection to an HTTP server.
    • Field Summary

      Fields
      Modifier and Type Field and Description
      protected int connectionTimeout
      The connection timeout for connecting the underlying socket.
      protected CookieManager cookieManager
      The cookie manager for this connection.
      protected java.lang.String hostname
      The host name of the server to connect to.
      static int HTTP_PORT
      The default HTTP port.
      static int HTTPS_PORT
      The default HTTPS port.
      protected java.io.InputStream in
      The socket input stream.
      protected int majorVersion
      The major version of HTTP supported by this client.
      protected int minorVersion
      The minor version of HTTP supported by this client.
      protected java.io.OutputStream out
      The socket output stream.
      protected int port
      The port to connect to.
      protected java.lang.String proxyHostname
      The host name of the proxy to connect to.
      protected int proxyPort
      The port on the proxy to connect to.
      protected boolean secure
      Whether the connection should use transport level security (HTTPS).
      protected java.net.Socket socket
      The socket this connection communicates on.
      protected int timeout
      The read timeout for reads on the underlying socket.
    • Constructor Summary

      Constructors
      Constructor and Description
      HTTPConnection (java.lang.String hostname)
      Creates a new HTTP connection.
      HTTPConnection (java.lang.String hostname, boolean secure)
      Creates a new HTTP or HTTPS connection.
      HTTPConnection (java.lang.String hostname, boolean secure, int connectionTimeout, int timeout)
      Creates a new HTTP or HTTPS connection on the specified port.
      HTTPConnection (java.lang.String hostname, int port)
      Creates a new HTTP connection on the specified port.
      HTTPConnection (java.lang.String hostname, int port, boolean secure)
      Creates a new HTTP or HTTPS connection on the specified port.
      HTTPConnection (java.lang.String hostname, int port, boolean secure, int connectionTimeout, int timeout)
      Creates a new HTTP or HTTPS connection on the specified port.
    • Field Detail

      • hostname

        protected final java.lang.String hostname
        The host name of the server to connect to.
      • port

        protected final int port
        The port to connect to.
      • secure

        protected final boolean secure
        Whether the connection should use transport level security (HTTPS).
      • connectionTimeout

        protected final int connectionTimeout
        The connection timeout for connecting the underlying socket.
      • timeout

        protected final int timeout
        The read timeout for reads on the underlying socket.
      • proxyHostname

        protected java.lang.String proxyHostname
        The host name of the proxy to connect to.
      • proxyPort

        protected int proxyPort
        The port on the proxy to connect to.
      • majorVersion

        protected int majorVersion
        The major version of HTTP supported by this client.
      • minorVersion

        protected int minorVersion
        The minor version of HTTP supported by this client.
      • socket

        protected java.net.Socket socket
        The socket this connection communicates on.
      • in

        protected java.io.InputStream in
        The socket input stream.
      • out

        protected java.io.OutputStream out
        The socket output stream.
      • cookieManager

        protected CookieManager cookieManager
        The cookie manager for this connection.
    • Constructor Detail

      • HTTPConnection

        public HTTPConnection(java.lang.String hostname)
        Creates a new HTTP connection.
        Parameters:
        hostname - the name of the host to connect to
      • HTTPConnection

        public HTTPConnection(java.lang.String hostname,
         boolean secure)
        Creates a new HTTP or HTTPS connection.
        Parameters:
        hostname - the name of the host to connect to
        secure - whether to use a secure connection
      • HTTPConnection

        public HTTPConnection(java.lang.String hostname,
         boolean secure,
         int connectionTimeout,
         int timeout)
        Creates a new HTTP or HTTPS connection on the specified port.
        Parameters:
        hostname - the name of the host to connect to
        secure - whether to use a secure connection
        connectionTimeout - the connection timeout
        timeout - the socket read timeout
      • HTTPConnection

        public HTTPConnection(java.lang.String hostname,
         int port)
        Creates a new HTTP connection on the specified port.
        Parameters:
        hostname - the name of the host to connect to
        port - the port on the host to connect to
      • HTTPConnection

        public HTTPConnection(java.lang.String hostname,
         int port,
         boolean secure)
        Creates a new HTTP or HTTPS connection on the specified port.
        Parameters:
        hostname - the name of the host to connect to
        port - the port on the host to connect to
        secure - whether to use a secure connection
      • HTTPConnection

        public HTTPConnection(java.lang.String hostname,
         int port,
         boolean secure,
         int connectionTimeout,
         int timeout)
        Creates a new HTTP or HTTPS connection on the specified port.
        Parameters:
        hostname - the name of the host to connect to
        port - the port on the host to connect to
        secure - whether to use a secure connection
        connectionTimeout - the connection timeout
        timeout - the socket read timeout
    • Method Detail

      • getHostName

        public java.lang.String getHostName()
        Returns the name of the host to connect to.
      • getPort

        public int getPort()
        Returns the port on the host to connect to.
      • isSecure

        public boolean isSecure()
        Indicates whether to use a secure connection or not.
      • getVersion

        public java.lang.String getVersion()
        Returns the HTTP version string supported by this connection.
        See Also:
        #version
      • setVersion

        public void setVersion(int majorVersion,
         int minorVersion)
        Sets the HTTP version supported by this connection.
        Parameters:
        majorVersion - the major version
        minorVersion - the minor version
      • setProxy

        public void setProxy(java.lang.String hostname,
         int port)
        Directs this connection to use the specified proxy.
        Parameters:
        hostname - the proxy host name
        port - the port on the proxy to connect to
      • isUsingProxy

        public boolean isUsingProxy()
        Indicates whether this connection is using an HTTP proxy.
      • setCookieManager

        public void setCookieManager(CookieManager cookieManager)
        Sets the cookie manager to use for this connection.
        Parameters:
        cookieManager - the cookie manager
      • getCookieManager

        public CookieManager getCookieManager()
        Returns the cookie manager in use for this connection.
      • newRequest

        public Request newRequest(java.lang.String method,
         java.lang.String path)
        Creates a new request using this connection.
        Parameters:
        method - the HTTP method to invoke
        path - the URI-escaped RFC2396 abs_path with optional query part
      • close

        public void close()
         throws java.io.IOException
        Closes this connection.
        Throws:
        java.io.IOException
      • getSocket

        protected java.net.Socket getSocket()
         throws java.io.IOException
        Retrieves the socket associated with this connection. This creates the socket if necessary.
        Throws:
        java.io.IOException
      • getInputStream

        protected java.io.InputStream getInputStream()
         throws java.io.IOException
        Throws:
        java.io.IOException
      • getOutputStream

        protected java.io.OutputStream getOutputStream()
         throws java.io.IOException
        Throws:
        java.io.IOException
      • closeConnection

        protected void closeConnection()
         throws java.io.IOException
        Closes the underlying socket, if any.
        Throws:
        java.io.IOException
      • getURI

        protected java.lang.String getURI()
        Returns a URI representing the connection. This does not include any request path component.
      • fireConnectionEvent

        protected void fireConnectionEvent(int type)
      • removeRequestListener

        public void removeRequestListener(RequestListener l)
      • fireRequestEvent

        protected void fireRequestEvent(int type,
         Request request)

AltStyle によって変換されたページ (->オリジナル) /