org.xwt
Class HTTP

java.lang.Object
  extended byorg.xwt.HTTP

public class HTTP
extends java.lang.Object

This object encapsulates a *single* HTTP connection. Multiple requests may be pipelined over a connection (thread-safe), although any IOException encountered in a request will invalidate all later requests.


Nested Class Summary
 class HTTP.HTTPInputStream
          An input stream that represents a subset of a longer input stream.
static class HTTP.Proxy
          encapsulates most of the proxy logic; some is shared in HTTP.java
 
Constructor Summary
HTTP(java.lang.String url)
           
HTTP(java.lang.String url, boolean skipResolveCheck)
           
 
Method Summary
 java.net.Socket attemptDirect()
          Attempts a direct connection
 java.net.Socket attemptHttpProxy(java.lang.String proxyHost, int proxyPort)
          Attempts to use an HTTP proxy, employing the CONNECT method if HTTPS is requested
 java.net.Socket attemptPAC(JS.Callable pacFunc)
          executes the PAC script and dispatches a call to one of the other attempt methods based on the result
 java.net.Socket attemptSocksProxy(java.lang.String proxyHost, int proxyPort)
          Implements SOCKSv4 with v4a DNS extension
 java.io.InputStream GET()
          Performs an HTTP GET request
 java.io.InputStream POST(java.lang.String contentType, java.lang.String content)
          Performs an HTTP POST request; content is appended to the headers (so it should include a blank line to delimit the beginning of the body)
 void sendRequest(java.lang.String contentType, java.lang.String content)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTP

public HTTP(java.lang.String url)

HTTP

public HTTP(java.lang.String url,
            boolean skipResolveCheck)
Method Detail

GET

public java.io.InputStream GET()
                        throws java.io.IOException
Performs an HTTP GET request

Throws:
java.io.IOException

POST

public java.io.InputStream POST(java.lang.String contentType,
                                java.lang.String content)
                         throws java.io.IOException
Performs an HTTP POST request; content is appended to the headers (so it should include a blank line to delimit the beginning of the body)

Throws:
java.io.IOException

attemptDirect

public java.net.Socket attemptDirect()
Attempts a direct connection


attemptHttpProxy

public java.net.Socket attemptHttpProxy(java.lang.String proxyHost,
                                        int proxyPort)
Attempts to use an HTTP proxy, employing the CONNECT method if HTTPS is requested


attemptSocksProxy

public java.net.Socket attemptSocksProxy(java.lang.String proxyHost,
                                         int proxyPort)
Implements SOCKSv4 with v4a DNS extension

See Also:
http://www.socks.nec.com/protocol/socks4.protocol, http://www.socks.nec.com/protocol/socks4a.protocol

attemptPAC

public java.net.Socket attemptPAC(JS.Callable pacFunc)
executes the PAC script and dispatches a call to one of the other attempt methods based on the result


sendRequest

public void sendRequest(java.lang.String contentType,
                        java.lang.String content)
                 throws java.io.IOException
Throws:
java.io.IOException