IT. Expert System.

Android Reference

AndroidHttpClient


android.net.http

Class AndroidHttpClient



  • public final class AndroidHttpClient
    extends Object
    Implementation of the Apache DefaultHttpClient that is configured with reasonable default settings and registered schemes for Android, and also lets the user add HttpRequestInterceptor classes. Don't create this directly, use the newInstance(java.lang.String, android.content.Context) factory method.

    This client processes cookies but does not retain them by default. To retain cookies, simply add a cookie store to the HttpContext:

    context.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
    • Field Detail

      • DEFAULT_SYNC_MIN_GZIP_BYTES

        public static long DEFAULT_SYNC_MIN_GZIP_BYTES
    • Method Detail

      • newInstance

        public static AndroidHttpClient newInstance(String userAgent,
                                    Context context)
        Create a new HttpClient with reasonable defaults (which you can update).
        Parameters:
        userAgent - to report in your HTTP requests
        context - to use for caching SSL sessions (may be null for no caching)
        Returns:
        AndroidHttpClient for you to use for all your requests.
      • newInstance

        public static AndroidHttpClient newInstance(String userAgent)
        Create a new HttpClient with reasonable defaults (which you can update).
        Parameters:
        userAgent - to report in your HTTP requests.
        Returns:
        AndroidHttpClient for you to use for all your requests.
      • finalize

        protected void finalize()
                         throws Throwable
        Description copied from class: Object
        Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.

        Note that objects that override finalize are significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.

        If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.

        Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.

        Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.

        Overrides:
        finalize in class Object
        Throws:
        Throwable
      • modifyRequestToAcceptGzipResponse

        public static void modifyRequestToAcceptGzipResponse(HttpRequest request)
        Modifies a request to indicate to the server that we would like a gzipped response. (Uses the "Accept-Encoding" HTTP header.)
        Parameters:
        request - the request to modify
        See Also:
        getUngzippedContent(HttpEntity)
      • getUngzippedContent

        public static InputStream getUngzippedContent(HttpEntity entity)
                                               throws IOException
        Gets the input stream from a response entity. If the entity is gzipped then this will get a stream over the uncompressed data.
        Parameters:
        entity - the entity whose content should be read
        Returns:
        the input stream to read from
        Throws:
        IOException
      • close

        public void close()
        Release resources associated with this client. You must call this, or significant resources (sockets and memory) may be leaked.
      • getParams

        public HttpParams getParams()
      • getConnectionManager

        public ClientConnectionManager getConnectionManager()
      • execute

        public HttpResponse execute(HttpUriRequest request,
                           HttpContext context)
                             throws IOException
        Throws:
        IOException
      • execute

        public HttpResponse execute(HttpHost target,
                           HttpRequest request)
                             throws IOException
        Throws:
        IOException
      • execute

        public HttpResponse execute(HttpHost target,
                           HttpRequest request,
                           HttpContext context)
                             throws IOException
        Throws:
        IOException
      • execute

        public <T> T execute(HttpUriRequest request,
                     responseHandler)
                  throws IOException,
                         ClientProtocolException
        Throws:
        IOException
        ClientProtocolException
      • execute

        public <T> T execute(HttpUriRequest request,
                     responseHandler,
                    HttpContext context)
                  throws IOException,
                         ClientProtocolException
        Throws:
        IOException
        ClientProtocolException
      • execute

        public <T> T execute(HttpHost target,
                    HttpRequest request,
                     responseHandler)
                  throws IOException,
                         ClientProtocolException
        Throws:
        IOException
        ClientProtocolException
      • execute

        public <T> T execute(HttpHost target,
                    HttpRequest request,
                     responseHandler,
                    HttpContext context)
                  throws IOException,
                         ClientProtocolException
        Throws:
        IOException
        ClientProtocolException
      • getCompressedEntity

        public static AbstractHttpEntity getCompressedEntity(byte[] data,
                                             ContentResolver resolver)
                                                      throws IOException
        Compress data to send to server. Creates a Http Entity holding the gzipped data. The data will not be compressed if it is too short.
        Parameters:
        data - The bytes to compress
        Returns:
        Entity holding the data
        Throws:
        IOException
      • getMinGzipSize

        public static long getMinGzipSize(ContentResolver resolver)
        Retrieves the minimum size for compressing data. Shorter data will not be compressed.
      • enableCurlLogging

        public void enableCurlLogging(String name,
                             int level)
        Enables cURL request logging for this client.
        Parameters:
        name - to log messages with
        level - at which to log messages (see Log)
      • disableCurlLogging

        public void disableCurlLogging()
        Disables cURL logging for this client.
      • parseDate

        public static long parseDate(String dateString)
        Returns the date of the given HTTP date string. This method can identify and parse the date formats emitted by common HTTP servers, such as RFC 822, RFC 850, RFC 1036, RFC 1123 and ANSI C's asctime().
        Returns:
        the number of milliseconds since Jan. 1, 1970, midnight GMT.
        Throws:
        IllegalArgumentException - if dateString is not a date or of an unsupported format.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 78 / 158852080. Delta: 0.12376 с