FileDocCategorySizeDatePackage
RequestWrapper.javaAPI DocAndroid 1.5 API5334Wed May 06 22:41:10 BST 2009org.apache.http.impl.client

RequestWrapper

public class RequestWrapper extends AbstractHttpMessage implements HttpUriRequest
A wrapper class for {@link HttpRequest}s that can be used to change properties of the current request without modifying the original object.

This class is also capable of resetting the request headers to the state of the original request.
author
Oleg Kalnichevski
version
$Revision: 674186 $
since
4.0

Fields Summary
private final HttpRequest
original
private URI
uri
private String
method
private ProtocolVersion
version
private int
execCount
Constructors Summary
public RequestWrapper(HttpRequest request)

        super();
        if (request == null) {
            throw new IllegalArgumentException("HTTP request may not be null");
        }
        this.original = request;
        setParams(request.getParams());
        // Make a copy of the original URI 
        if (request instanceof HttpUriRequest) {
            this.uri = ((HttpUriRequest) request).getURI();
            this.method = ((HttpUriRequest) request).getMethod();
            this.version = null;
        } else {
            RequestLine requestLine = request.getRequestLine();
            try {
                this.uri = new URI(requestLine.getUri());
            } catch (URISyntaxException ex) {
                throw new ProtocolException("Invalid request URI: " 
                        + requestLine.getUri(), ex);
            }
            this.method = requestLine.getMethod();
            this.version = request.getProtocolVersion();
        }
        this.execCount = 0;
    
Methods Summary
public voidabort()

        throw new UnsupportedOperationException();
    
public intgetExecCount()

        return this.execCount;
    
public java.lang.StringgetMethod()

        return this.method;
    
public org.apache.http.HttpRequestgetOriginal()

        return this.original;
    
public org.apache.http.ProtocolVersiongetProtocolVersion()

        if (this.version != null) {
            return this.version;
        } else {
            return HttpProtocolParams.getVersion(getParams());
        }
    
public org.apache.http.RequestLinegetRequestLine()

        String method = getMethod();
        ProtocolVersion ver = getProtocolVersion();
        String uritext = null;
        if (uri != null) {
            uritext = uri.toASCIIString();
        }
        if (uritext == null || uritext.length() == 0) {
            uritext = "/";
        }
        return new BasicRequestLine(method, uritext, ver);
    
public java.net.URIgetURI()

        return this.uri;
    
public voidincrementExecCount()

        this.execCount++;
    
public booleanisAborted()

        return false;
    
public booleanisRepeatable()

        return true;
    
public voidresetHeaders()

        // Make a copy of original headers
        this.headergroup.clear();
        setHeaders(this.original.getAllHeaders());
    
public voidsetMethod(java.lang.String method)

        if (method == null) {
            throw new IllegalArgumentException("Method name may not be null");
        }
        this.method = method;
    
public voidsetProtocolVersion(org.apache.http.ProtocolVersion version)

        this.version = version;
    
public voidsetURI(java.net.URI uri)

        this.uri = uri;