| org.apache.commons.httpclient |
Package Documentation for org.apache.commons.httpclient
Classes and interfaces supporting the client side of the HTTP protocol.
The HttpClient component supports the client-side of
RFC 1945 (HTTP/1.0) and
RFC 2616 (HTTP/1.1),
several related specifications
(RFC 2109 (Cookies),
RFC 2617 (HTTP Authentication),
etc.), and provides a framework by which new request types (methods) or HTTP
extensions can can be easily created or supported.
The basis for the abstraction is provided by three types:
- {@link org.apache.commons.httpclient.HttpConnection}
-
represents a network connection to some HTTP host.
- {@link org.apache.commons.httpclient.HttpMethod}
-
represents a request to be made over some
{@link org.apache.commons.httpclient.HttpConnection}
and contains the server's response.
- {@link org.apache.commons.httpclient.HttpState}
-
contains the HTTP attributes that may persist from
request to request, such as cookies and authentication
credentials.
and several simple bean-style classes:
- {@link org.apache.commons.httpclient.Cookie}
-
represents HTTP cookie.
- {@link org.apache.commons.httpclient.Credentials}
-
an interface representing a set of authentication credentials.
- {@link org.apache.commons.httpclient.Header}
-
represents an HTTP request or response header.
- {@link org.apache.commons.httpclient.HeaderElement}
-
represents a single element of a multi-part header.
- {@link org.apache.commons.httpclient.UsernamePasswordCredentials}
-
a username and password pair.
{@link org.apache.commons.httpclient.HttpClient} provides a
simple "user-agent" implementation that will suffice for many
applications, but whose use is not required.
HttpClient also provides several utilities that may be
useful when extending the framework:
- {@link org.apache.commons.httpclient.HttpMethodBase}
-
an abstract base implementation of HttpMethod,
which may be extended to create new method types or
to support additional protocol HTTP features.
- {@link org.apache.commons.httpclient.HttpStatus}
-
an enumeration of HttpStatus codes.
- {@link org.apache.commons.httpclient.ChunkedOutputStream}
-
an {@link java.io.OutputStream} wrapper supporting the "chunked"
transfer encoding.
- {@link org.apache.commons.httpclient.ChunkedInputStream}
-
an {@link java.io.InputStream} wrapper supporting the "chunked"
transfer encoding.
- {@link org.apache.commons.httpclient.util.URIUtil}
-
provides utilities for encoding and decoding URI's in the
%HH format.
HttpClient Configuration with Java Properties
Java properties can be set at run time with the -Dname=value
command line arguments to the application that uses HttpClient.
These properties can also be set programaticly by calling
System.getProperties().setProperty(name, value).
This is the list of properties that HttpClient recognizes:
| Name |
Type |
Effect |
| httpclient.useragent |
String |
Sets the User-Agent string to be sent on every HTTP request. |
| httpclient.authentication.preemptive |
boolean |
Sends authorization credentials without requiring explicit requests
from the web server |
|
| Java Source File Name | Type | Comment |
| AccessibleHttpConnectionManager.java | Class | A simple connection manager that provides access to the connection used. |
| AutoCloseInputStream.java | Class | Closes an underlying stream as soon as the end of the stream is reached, and
notifies a client when it has done so. |
| ChunkedInputStream.java | Class | Transparently coalesces chunks of a HTTP stream that uses
Transfer-Encoding chunked.
Note that this class NEVER closes the underlying stream, even when close
gets called. |
| ChunkedOutputStream.java | Class | Implements HTTP chunking support. |
| CircularRedirectException.java | Class | |
| ConnectionPoolTimeoutException.java | Class | A timeout while connecting waiting for an available connection
from an HttpConnectionManager. |
| ConnectMethod.java | Class | Establishes a tunneled HTTP connection via the CONNECT method. |
| ConnectTimeoutException.java | Class | A timeout while connecting to an HTTP server or waiting for an
available connection from an HttpConnectionManager. |
| ContentLengthInputStream.java | Class | Cuts the wrapped InputStream off after a specified number of bytes.
Implementation note: Choices abound. |
| Cookie.java | Class |
HTTP "magic-cookie" represents a piece of state information
that the HTTP agent and the target server can exchange to maintain
a session.
author: B.C. |
| Credentials.java | Interface | Authentication credentials.
This is just a marker interface, the current implementation has no methods. |
| DefaultHttpMethodRetryHandler.java | Class | The default
HttpMethodRetryHandler used by
HttpMethod s. |
| DefaultMethodRetryHandler.java | Class | The default MethodRetryHandler used by HttpMethodBase. |
| EchoService.java | Class | A service that echos the request body. |
| ExecuteMethodThread.java | Class | Executes a method from a new thread. |
| FakeHttpMethod.java | Class | For test-nohost testing purposes only. |
| FeedbackService.java | Class | |
| Header.java | Class | |
| HeaderElement.java | Class | One element of an HTTP header's value.
Some HTTP headers (such as the set-cookie header) have values that
can be decomposed into multiple elements. |
| HeaderGroup.java | Class | A class for combining a set of headers. |
| HostConfiguration.java | Class | Holds all of the variables needed to describe an HTTP connection to a host. |
| HttpClient.java | Class |
An HTTP "user-agent", containing an
HttpState HTTP state and
one or more
HttpConnection HTTP connections , to which
HttpMethod HTTP methods can be applied.
author: Remy Maucherat author: Rodney Waldhoff author: Sean C. |
| HttpClientError.java | Class | Signals that an error has occurred. |
| HttpClientTestBase.java | Class | Base class for test cases using
org.apache.commons.httpclient.server.SimpleHttpServer based
testing framework. |
| HttpConnection.java | Class | An abstraction of an HTTP
InputStream and
OutputStream pair, together with the relevant attributes.
The following options are set on the socket before getting the input/output
streams in the
HttpConnection.open() method:
author: Rod Waldhoff author: Sean C. |
| HttpConnectionManager.java | Interface | An interface for classes that manage HttpConnections. |
| HttpConstants.java | Class | HTTP content conversion routines. |
| HttpContentTooLargeException.java | Class | Signals that the response content was larger than anticipated. |
| HttpException.java | Class | Signals that an HTTP or HttpClient exception has occurred. |
| HttpHost.java | Class | Holds all of the variables needed to describe an HTTP connection to a host. |
| HttpMethod.java | Interface |
HttpMethod interface represents a request to be sent via a
HttpConnection HTTP connection and a corresponding response. |
| HttpMethodBase.java | Class | An abstract base implementation of HttpMethod.
At minimum, subclasses will need to override:
When a method requires additional request headers, subclasses will typically
want to override:
When a method expects specific response headers, subclasses may want to
override:
author: Remy Maucherat author: Rodney Waldhoff author: Sean C. |
| HttpMethodDirector.java | Class | Handles the process of executing a method including authentication, redirection and retries. |
| HttpMethodRetryHandler.java | Interface | A handler for determining if an HttpMethod should be retried after a
recoverable exception during execution. |
| HttpParser.java | Class | A utility class for parsing http header values according to
RFC-2616 Section 4 and 19.3. |
| HttpRecoverableException.java | Class |
Signals that an HTTP or HttpClient exception has occurred. |
| HttpState.java | Class |
A container for HTTP attributes that may persist from request
to request, such as
Cookie cookies and authentication
Credentials credentials .
author: Remy Maucherat author: Rodney Waldhoff author: Jeff Dever author: Sean C. |
| HttpStatus.java | Class | Constants enumerating the HTTP status codes. |
| HttpsURL.java | Class | The HTTPS URL. |
| HttpURL.java | Class | The HTTP URL. |
| HttpVersion.java | Class | HTTP version, as specified in RFC 2616.
HTTP uses a "<major>.<minor>" numbering scheme to indicate
versions of the protocol. |
| InvalidRedirectLocationException.java | Class | |
| MethodRetryHandler.java | Interface | A handler for determining if an HttpMethod should be retried after a
recoverable exception during execution. |
| MultiThreadedHttpConnectionManager.java | Class | Manages a set of HttpConnections for various HostConfigurations.
author: Michael Becke author: Eric Johnson author: Mike Bowler author: Carl A. |
| NameValuePair.java | Class | A simple class encapsulating a name/value pair.
author: B.C. |
| NoHostHttpConnectionManager.java | Class | |
| NoHttpResponseException.java | Class |
Signals that the target server failed to respond with a valid HTTP response. |
| NoncompliantHeadMethod.java | Class | |
| NoncompliantPostMethod.java | Class | |
| NTCredentials.java | Class | Credentials for use with the NTLM authentication scheme which requires additional
information. |
| ProtocolException.java | Class | Signals that an HTTP protocol violation has occurred. |
| ProxyClient.java | Class | A client that provides
java.net.Socket sockets for communicating through HTTP proxies
via the HTTP CONNECT method. |
| ProxyHost.java | Class | Holds all of the variables needed to describe an HTTP connection to a proxy. |
| ProxyTestDecorator.java | Class | A TestDecorator that configures instances of HttpClientTestBase to use
a proxy server. |
| RedirectException.java | Class | |
| ResponseConsumedWatcher.java | Interface | When a response stream has been consumed, various parts of the HttpClient
implementation need to respond appropriately. |
| SimpleHttpConnectionManager.java | Class | A connection manager that provides access to a single HttpConnection. |
| StatusLine.java | Class | Represents a Status-Line as returned from a HTTP server.
RFC2616 states
the following regarding the Status-Line:
6.1 Status-Line
The first line of a Response message is the Status-Line, consisting
of the protocol version followed by a numeric status code and its
associated textual phrase, with each element separated by SP
characters. |
| TestAll.java | Class | |
| TestBadContentLength.java | Class | Tests HttpClient's behaviour when receiving more response data than expected. |
| TestConnectionPersistence.java | Class | |
| TestCredentials.java | Class | Unit tests for
Credentials . |
| TestEffectiveHttpVersion.java | Class | HTTP protocol versioning tests. |
| TestEntityEnclosingMethod.java | Class | Tests specific to entity enclosing methods. |
| TestEquals.java | Class | |
| TestExceptions.java | Class | |
| TestHeader.java | Class | Simple tests for
NameValuePair . |
| TestHeaderElement.java | Class | Simple tests for
HeaderElement .
author: Rodney Waldhoff author: B.C. |
| TestHeaderOps.java | Class | |
| TestHostConfiguration.java | Class | Tests basic HostConfiguration functionality. |
| TestHttpConnection.java | Class | Unit tests for
HttpConnection .
author: Sean C. |
| TestHttpConnectionManager.java | Class | Unit tests for
HttpConnectionManager .
author: Marc A. |
| TestHttpMethodFundamentals.java | Class | Tests basic method functionality. |
| TestHttpParser.java | Class | Simple tests for
HttpParser . |
| TestHttps.java | Class | Simple tests for HTTPS support in HttpClient.
To run this test you'll need:
+ a JSSE implementation installed (see README.txt)
+ the java.protocol.handler.pkgs system property set
for your provider. |
| TestHttpState.java | Class | Simple tests for
HttpState .
author: Rodney Waldhoff author: Jeff Dever author: Sean C. |
| TestHttpStatus.java | Class | Unit tests for
HttpStatus author: Sean C. |
| TestHttpVersion.java | Class | |
| TestIdleConnectionTimeout.java | Class | |
| TestMethodAbort.java | Class | Tests ability to abort method execution. |
| TestMethodCharEncoding.java | Class | |
| TestMultipartPost.java | Class | Webapp tests specific to the MultiPostMethod. |
| TestNoHost.java | Class | Tests that don't require any external host. |
| TestNoncompliant.java | Class | Tests handling of non-compliant responses. |
| TestNVP.java | Class | Simple tests for
NameValuePair . |
| TestParameterFormatter.java | Class | Unit tests for
ParameterFormatter . |
| TestParameterParser.java | Class | Unit tests for
ParameterParser . |
| TestPartsNoHost.java | Class | |
| TestPostMethod.java | Class | Webapp tests specific to the PostMethod. |
| TestPostParameterEncoding.java | Class | Tests basic method functionality. |
| TestProxy.java | Class | Tests for proxied connections. |
| TestProxyWithRedirect.java | Class | Tests for proxied connections. |
| TestQueryParameters.java | Class | |
| TestRedirects.java | Class | Redirection test cases. |
| TestRequestHeaders.java | Class | Tests for reading response headers. |
| TestRequestLine.java | Class | Simple tests for
StatusLine . |
| TestResponseHeaders.java | Class | Tests for reading response headers. |
| TestStatusLine.java | Class | Simple tests for
StatusLine . |
| TestStreams.java | Class | |
| TestURI.java | Class | Simple tests for the URI class. |
| TestURIUtil.java | Class | Unit tests for
URIUtil . |
| TestURIUtil2.java | Class | Tests the util.URIUtil class. |
| TestVirtualHost.java | Class | HTTP protocol versioning tests. |
| URI.java | Class | The interface for the URI(Uniform Resource Identifiers) version of RFC 2396.
This class has the purpose of supportting of parsing a URI reference to
extend any specific protocols, the character encoding of the protocol to
be transported and the charset of the document.
A URI is always in an "escaped" form, since escaping or unescaping a
completed URI might change its semantics. |
| URIException.java | Class | The URI parsing and escape encoding exception. |
| UsernamePasswordCredentials.java | Class | Username and password
Credentials .
author: Remy Maucherat author: Sean C. |
| Wire.java | Class | Logs data to the wire LOG. |
| WireLogInputStream.java | Class | Logs all data read to the wire LOG. |
| WireLogOutputStream.java | Class | Logs all data written to the wire LOG. |