FileDocCategorySizeDatePackage
HttpRequestBase.javaAPI DocAndroid 1.5 API5832Wed May 06 22:41:10 BST 2009org.apache.http.client.methods

HttpRequestBase

public abstract class HttpRequestBase extends AbstractHttpMessage implements HttpUriRequest, AbortableHttpRequest, Cloneable
Basic implementation of an HTTP request that can be modified.
author
Oleg Kalnichevski
version
$Revision: 674186 $
since
4.0

Fields Summary
private Lock
abortLock
private boolean
aborted
private URI
uri
private ClientConnectionRequest
connRequest
private ConnectionReleaseTrigger
releaseTrigger
Constructors Summary
public HttpRequestBase()

        super();
        this.abortLock = new ReentrantLock();
    
Methods Summary
public voidabort()

        ClientConnectionRequest localRequest;
        ConnectionReleaseTrigger localTrigger;
        
        this.abortLock.lock();
        try {
            if (this.aborted) {
                return;
            }            
            this.aborted = true;
            
            localRequest = connRequest;
            localTrigger = releaseTrigger;
        } finally {
            this.abortLock.unlock();
        }        

        // Trigger the callbacks outside of the lock, to prevent
        // deadlocks in the scenario where the callbacks have
        // their own locks that may be used while calling
        // setReleaseTrigger or setConnectionRequest.
        if (localRequest != null) {
            localRequest.abortRequest();
        }
        if (localTrigger != null) {
            try {
                localTrigger.abortConnection();
            } catch (IOException ex) {
                // ignore
            }
        }
    
public java.lang.Objectclone()

        HttpRequestBase clone = (HttpRequestBase) super.clone();
        clone.abortLock = new ReentrantLock();
        clone.aborted = false;
        clone.releaseTrigger = null;
        clone.connRequest = null;
        clone.headergroup = (HeaderGroup) CloneUtils.clone(this.headergroup);
        clone.params = (HttpParams) CloneUtils.clone(this.params);
        return clone;
    
public abstract java.lang.StringgetMethod()

public org.apache.http.ProtocolVersiongetProtocolVersion()

        return HttpProtocolParams.getVersion(getParams());
    
public org.apache.http.RequestLinegetRequestLine()

        String method = getMethod();
        ProtocolVersion ver = getProtocolVersion();
        URI uri = getURI();
        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 booleanisAborted()

        return this.aborted;
    
public voidsetConnectionRequest(org.apache.http.conn.ClientConnectionRequest connRequest)

        this.abortLock.lock();
        try {
            if (this.aborted) {
                throw new IOException("Request already aborted");
            }
            
            this.releaseTrigger = null;
            this.connRequest = connRequest;
        } finally {
            this.abortLock.unlock();
        }
    
public voidsetReleaseTrigger(org.apache.http.conn.ConnectionReleaseTrigger releaseTrigger)

        this.abortLock.lock();
        try {
            if (this.aborted) {
                throw new IOException("Request already aborted");
            }
            
            this.connRequest = null;
            this.releaseTrigger = releaseTrigger;
        } finally {
            this.abortLock.unlock();
        }
    
public voidsetURI(java.net.URI uri)

        this.uri = uri;