FileDocCategorySizeDatePackage
DefaultHttpResponseFactory.javaAPI DocAndroid 1.5 API4496Wed May 06 22:41:10 BST 2009org.apache.http.impl

DefaultHttpResponseFactory

public class DefaultHttpResponseFactory extends Object implements HttpResponseFactory
Default implementation of a factory for creating response objects.
author
Oleg Kalnichevski
version
$Revision: 618367 $
since
4.0

Fields Summary
protected final ReasonPhraseCatalog
reasonCatalog
The catalog for looking up reason phrases.
Constructors Summary
public DefaultHttpResponseFactory(ReasonPhraseCatalog catalog)
Creates a new response factory with the given catalog.

param
catalog the catalog of reason phrases

        if (catalog == null) {
            throw new IllegalArgumentException
                ("Reason phrase catalog must not be null.");
        }
        this.reasonCatalog = catalog;
    
public DefaultHttpResponseFactory()
Creates a new response factory with the default catalog. The default catalog is {@link EnglishReasonPhraseCatalog EnglishReasonPhraseCatalog}.

        this(EnglishReasonPhraseCatalog.INSTANCE);
    
Methods Summary
protected java.util.LocaledetermineLocale(org.apache.http.protocol.HttpContext context)
Determines the locale of the response. The implementation in this class always returns the default locale.

param
context the context from which to determine the locale, or null to use the default locale
return
the locale for the response, never null

        return Locale.getDefault();
    
public org.apache.http.HttpResponsenewHttpResponse(org.apache.http.ProtocolVersion ver, int status, org.apache.http.protocol.HttpContext context)

        if (ver == null) {
            throw new IllegalArgumentException("HTTP version may not be null");
        }
        final Locale loc      = determineLocale(context);
        final String reason   = reasonCatalog.getReason(status, loc);
        StatusLine statusline = new BasicStatusLine(ver, status, reason);
        return new BasicHttpResponse(statusline, reasonCatalog, loc); 
    
public org.apache.http.HttpResponsenewHttpResponse(org.apache.http.StatusLine statusline, org.apache.http.protocol.HttpContext context)

        if (statusline == null) {
            throw new IllegalArgumentException("Status line may not be null");
        }
        final Locale loc = determineLocale(context);
        return new BasicHttpResponse(statusline, reasonCatalog, loc);