# Class ConnectionRequest

java.lang.Object
com.codename1.io.ConnectionRequest

All Implemented Interfaces:
  `IOProgressListener`

Direct Known Subclasses:
  `AdsService, CachedDataService, GZConnectionRequest, ImageDownloadService, MultipartRequest, RSSService, TwitterRESTService`

public class ConnectionRequest extends Object implements IOProgressListener

This class represents a connection object in the form of a request response typically common for HTTP/HTTPS connections. A connection request is added to the `com.codename1.io.NetworkManager` for processing in a queue on one of the network threads. You can read more about networking in Codename One `here`

The sample code below fetches a page of data from the nestoria housing listing API.

You can see instructions on how to display the data in the `com.codename1.components.InfiniteScrollAdapter` class. You can read more about networking in Codename One `here`.

    int pageNumber = 1;
    java.util.List<Map<String, Object>> fetchPropertyData(String text) {
        try {
            ConnectionRequest r = new ConnectionRequest();
            r.setPost(false);
            r.setUrl("http://api.nestoria.co.uk/api");
            r.addArgument("pretty", "0");
            r.addArgument("action", "search_listings");
            r.addArgument("encoding", "json");
            r.addArgument("listing_type", "buy");
            r.addArgument("page", "" + pageNumber);
            pageNumber++;
            r.addArgument("country", "uk");
            r.addArgument("place_name", text);
            NetworkManager.getInstance().addToQueueAndWait(r);
            Map result = new JSONParser().parseJSON(new InputStreamReader(new ByteArrayInputStream(r.getResponseData()), "UTF-8"));
            Map response = (Map)result.get("response");
            return (java.util.List<Map<String, Object>>)response.get("listings");
        } catch(Exception err) {
            Log.e(err);
            return null;
        }
    }

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `ConnectionRequest.CachingMode`
  There are 5 caching modes:
  `static final class`
  `ConnectionRequest.SSLCertificate`
  Encapsulates an SSL certificate fingerprint.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final byte`
  `PRIORITY_CRITICAL`
  A critical priority request will "push" through the queue to the highest point regardless of anything else and ignoring anything that is not in itself of critical priority.
  `static final byte`
  `PRIORITY_HIGH`
  A high priority request is the second highest level, it will act exactly like a critical priority with one difference.
  `static final byte`
  `PRIORITY_LOW`
  Low priority requests are mostly background tasks that should still be accomplished though
  `static final byte`
  `PRIORITY_NORMAL`
  Normal priority executes as usual on the queue
  `static final byte`
  `PRIORITY_REDUNDANT`
  Redundant elements can be discarded from the queue when paused

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ConnectionRequest()`
  Default constructor
  `ConnectionRequest(String url)`
  Construct a connection request to a url
  `ConnectionRequest(String url, boolean post)`
  Construct a connection request to a url

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addArgument(String key, byte[] value)`
  Add an argument to the request response
  `void`
  `addArgument(String key, String value)`
  Add an argument to the request response
  `void`
  `addArgument(String key, String[] value)`
  Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same key
  `void`
  `addArgumentArray(String key, String... value)`
  Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same key
  `void`
  `addArgumentNoEncoding(String key, String value)`
  Add an argument to the request response without encoding it, this is useful for arguments which are already encoded
  `void`
  `addArgumentNoEncoding(String key, String[] value)`
  Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same key, notice that this doesn't implicitly encode the value
  `void`
  `addArgumentNoEncodingArray(String key, String... value)`
  Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same key, notice that this doesn't implicitly encode the value
  `void`
  `addArguments(String key, String... value)`
  Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same key
  `void`
  `addExceptionListener(ActionListener<NetworkEvent> a)`
  Adds a listener that would be notified on the CodenameOne thread of an exception in this connection request
  `void`
  `addRequestHeader(String key, String value)`
  Adds the given header to the request that will be sent
  `void`
  `addResponseCodeListener(ActionListener<NetworkEvent> a)`
  Adds a listener that would be notified on the CodenameOne thread of a response code that is not a 200 (OK) or 301/2 (redirect) response code.
  `void`
  `addResponseListener(ActionListener<NetworkEvent> a)`
  Adds a listener that would be notified on the CodenameOne thread of a response from the server.
  `protected void`
  `buildRequestBody(OutputStream os)`
  Invoked when send body is true, by default sends the request arguments based on "POST" conventions
  `protected void`
  `cacheUnmodified()`
  This callback is invoked on a 304 server response indicating the data in the server matches the result we currently have in the cache.
  `boolean`
  `canGetSSLCertificates()`
  Checks to see if the platform supports getting SSL certificates.
  `protected void`
  `checkSSLCertificates(ConnectionRequest.SSLCertificate[] certificates)`
  A callback that can be overridden by subclasses to check the SSL certificates for the server, and kill the connection if they don't pass muster.
  `protected void`
  `cookieReceived(Cookie c)`
  Callback invoked for every cookie received from the server
  `protected void`
  `cookieSent(Cookie c)`
  Callback invoked for every cookie being sent to the server
  `protected String`
  `createRequestURL()`
  Creates the request URL mostly for a get request
  `AsyncResource<Image>`
  `downloadImageToFileSystem(String file)`
  Downloads an image to the file system asynchronously returning an AsyncResource object that resolves to the loaded image..
  `AsyncResource<Image>`
  `downloadImageToFileSystem(String file, boolean useCache)`
  Downloads an image to a the file system asynchronously returning an AsyncResource object that resolves to the loaded image..
  `void`
  `downloadImageToFileSystem(String file, SuccessCallback<Image> onSuccess)`
  Downloads an image to a the file system asynchronously and calls the onSuccessCallback with the resulting image.
  `void`
  `downloadImageToFileSystem(String file, SuccessCallback<Image> onSuccess, boolean useCache)`
  Downloads an image to a the file system asynchronously and calls the onSuccessCallback with the resulting image.
  `void`
  `downloadImageToFileSystem(String file, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail)`
  Downloads an image to a the file system asynchronously and calls the onSuccessCallback with the resulting image.
  `void`
  `downloadImageToFileSystem(String file, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail, boolean useCache)`
  Downloads an image to a the file system asynchronously and calls the onSuccessCallback with the resulting image.
  `AsyncResource<Image>`
  `downloadImageToStorage(String storageFile)`
  Downloads an image to a specified storage file asynchronously returning an AsyncResource that resolves to the resulting image..
  `AsyncResource<Image>`
  `downloadImageToStorage(String storageFile, boolean useCache)`
  Downloads an image to a specified storage file asynchronously returning an AsyncResource that resolves to the resulting image..
  `void`
  `downloadImageToStorage(String storageFile, SuccessCallback<Image> onSuccess)`
  Downloads an image to a specified storage file asynchronously and calls the onSuccessCallback with the resulting image.
  `void`
  `downloadImageToStorage(String storageFile, SuccessCallback<Image> onSuccess, boolean useCache)`
  Downloads an image to a specified storage file asynchronously and calls the onSuccessCallback with the resulting image.
  `void`
  `downloadImageToStorage(String storageFile, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail)`
  Downloads an image to a specified storage file asynchronously and calls the onSuccessCallback with the resulting image.
  `void`
  `downloadImageToStorage(String storageFile, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail, boolean useCache)`
  Downloads an image to a specified storage file asynchronously and calls the onSuccessCallback with the resulting image.
  `boolean`
  `equals(Object o)`
  Indicates whether some other object is "equal to" this one.
  `static Map<String,Object>`
  `fetchJSON(String url)`
  Utility method that returns a JSON structure or throws an IOException in case of a failure.
  `static AsyncResource<Map<String,Object>>`
  `fetchJSONAsync(String url)`
  Fetches JSON asynchronously.
  `protected void`
  `fireResponseListener(ActionEvent ev)`
  Fires the response event to the listeners on this connection
  `protected InputStream`
  `getCachedData()`
  This method should be overriden in `CacheMode.MANUAL` to provide offline caching.
  `ConnectionRequest.CachingMode`
  `getCacheMode()`
  There are 5 caching modes:
  `int`
  `getContentLength()`
  Returns the content length header value
  `String`
  `getContentType()`

  ###### Returns

  `static String`
  `getCookieHeader()`
  Workaround for https://bugs.php.net/bug.php?id=65633 allowing developers to customize the name of the cookie header to Cookie
  `static ConnectionRequest.CachingMode`
  `getDefaultCacheMode()`
  The default value for the cacheMode property see `#getCacheMode()`
  `static String`
  `getDefaultUserAgent()`

  ###### Returns

  `String`
  `getDestinationFile()`
  When set to a none null string saves the response to file system under this file name
  `String`
  `getDestinationStorage()`
  When set to a none null string saves the response to storage under this file name
  `Dialog`
  `getDisposeOnCompletion()`
  A dialog that will be seamlessly disposed once the given request has been completed
  `protected String`
  `getHeader(Object connection, String header)`
  Returns the HTTP header field for the given connection, this method is only guaranteed to work when invoked from the readHeaders method.
  `protected String[]`
  `getHeaderFieldNames(Object connection)`
  Returns the HTTP header field names for the given connection, this method is only guaranteed to work when invoked from the readHeaders method.
  `protected String[]`
  `getHeaders(Object connection, String header)`
  Returns the HTTP header field for the given connection, this method is only guaranteed to work when invoked from the readHeaders method.
  `String`
  `getHttpMethod()`
  Returns the http method
  `byte`
  `getPriority()`
  The priority of this connection based on the constants in this class
  `int`
  `getReadTimeout()`
  Gets the read timeout for this connection.
  `String`
  `getRequestBody()`
  The request body can be used instead of arguments to pass JSON data to a restful request, it can't be used in a get request and will fail if you have arguments
  `Data`
  `getRequestBodyData()`
  The request body can be used instead of arguments to pass JSON data to a restful request, it can't be used in a get request and will fail if you have arguments
  `int`
  `getResponseCode()`
  Returns the response code for this request, this is only relevant after the request completed and might contain a temporary (e.g. redirect) code while the request is in progress
  `String`
  `getResponseContentType()`
  Returns the content type from the response headers
  `byte[]`
  `getResponseData()`
  This method will return a valid value for only some of the responses and only after the response was processed
  `String`
  `getResponseErrorMessage()`
  Returns error message associated with an error response code
  `int`
  `getResposeCode()`
  Returns the response code for this request, this is only relevant after the request completed and might contain a temporary (e.g. redirect) code while the request is in progress
  `Dialog`
  `getShowOnInit()`
  This dialog will be shown when this request enters the network queue
  `int`
  `getSilentRetryCount()`
  Indicates the number of times to silently retry a connection that failed before prompting
  `ConnectionRequest.SSLCertificate[]`
  `getSSLCertificates()`
  Gets the server's SSL certificates for this requests.
  `int`
  `getTimeout()`
  Indicates the timeout for this connection request
  `String`
  `getUrl()`

  ###### Returns

  `String`
  `getUserAgent()`

  ###### Returns

  `protected int`
  `getYield()`
  Returns the amount of time to yield for other processes, this is an implicit method that automatically generates values for lower priority connections
  `protected void`
  `handleErrorResponseCode(int code, String message)`
  Handles a server response code that is not 200 and not a redirect (unless redirect handling is disabled)
  `protected void`
  `handleException(Exception err)`
  Handles an exception thrown when performing a network operation, the default implementation shows a retry dialog.
  `protected void`
  `handleIOException(IOException err)`
  Handles IOException thrown when performing a network operation
  `protected void`
  `handleRuntimeException(RuntimeException err)`
  Handles an exception thrown when performing a network operation
  `int`
  `hashCode()`
  Returns a hash code value for the object.
  `protected boolean`
  `hasResponseListeners()`
  Returns true if someone is listening to action response events, this is useful so we can decide whether to bother collecting data for an event in some cases since building the event object might be memory/CPU intensive.
  `protected void`
  `initConnection(Object connection)`
  Invoked to initialize HTTP headers, cookies etc.
  `protected String`
  `initCookieHeader(String cookie)`
  Allows subclasses to inject cookies into the request
  `void`
  `ioStreamUpdate(Object source, int bytes)`
  Indicates the number of bytes that were read/written to/from the source stream
  `boolean`
  `isCheckSSLCertificates()`

  ###### Returns

  `boolean`
  `isCookiesEnabled()`

  ###### Returns

  `static boolean`
  `isCookiesEnabledDefault()`

  ###### Returns

  `static boolean`
  `isDefaultFollowRedirects()`
  Enables/Disables automatic redirects globally and returns the 302 error code, IMPORTANT this feature doesn't work on all platforms and currently doesn't work on iOS which always implicitly redirects
  `boolean`
  `isDuplicateSupported()`
  Indicates whether this connection request supports duplicate entries in the request queue
  `boolean`
  `isFailSilently()`
  Indicates that we are uninterested in error handling
  `boolean`
  `isFollowRedirects()`
  Enables/Disables automatic redirects globally and returns the 302 error code, IMPORTANT this feature doesn't work on all platforms and currently doesn't work on iOS which always implicitly redirects
  `static boolean`
  `isHandleErrorCodesInGlobalErrorHandler()`
  When set to true (the default), the global error handler in `NetworkManager` should receive errors for response code as well
  `boolean`
  `isInsecure()`
  Checks if the request is insecure (default false).
  `protected boolean`
  `isKilled()`

  ###### Returns

  `static boolean`
  `isNativeCookieSharingSupported()`
  Checks if the platform supports sharing cookies between the native components (e.g. BrowserComponent) and ConnectionRequests.
  `protected boolean`
  `isPausable()`
  Return true from this method if this connection can be paused and resumed later on.
  `protected boolean`
  `isPaused()`

  ###### Returns

  `boolean`
  `isPost()`
  Returns true for a post operation and false for a get operation
  `boolean`
  `isReadRequest()`

  ###### Returns

  `boolean`
  `isReadResponseForErrors()`
  When set to true the read response code will happen even for error codes such as 400 and 500
  `static boolean`
  `isReadResponseForErrorsDefault()`
  Determines the default value for `#isReadResponseForErrors()`
  `static boolean`
  `isReadTimeoutSupported()`
  Checks if this platform supports read timeouts.
  `boolean`
  `isRedirecting()`
  Returns true if this request is been redirected to a different url
  `boolean`
  `isWriteRequest()`

  ###### Returns

  `void`
  `kill()`
  Kills this request if possible
  `boolean`
  `onRedirect(String url)`
  This is a callback method that been called when there is a redirect.
  `boolean`
  `pause()`
  Invoked to pause this opeation, this method will only be invoked if isPausable() returns true (its false by default).
  `protected void`
  `postResponse()`
  A callback method that's invoked on the EDT after the readResponse() method has finished, this is the place where developers should change their Codename One user interface to avoid race conditions that might be triggered by modifications within readResponse.
  `void`
  `purgeCache()`
  Deletes the cache file if it exists, notice that this will not work for download files
  `static void`
  `purgeCacheDirectory()`
  Purges all locally cached files
  `protected void`
  `readErrorCodeHeaders(Object connection)`
  Allows reading the headers from the connection by calling the getHeader() method when a response that isn't 200 OK is sent.
  `protected void`
  `readHeaders(Object connection)`
  Allows reading the headers from the connection by calling the getHeader() method.
  `protected void`
  `readResponse(InputStream input)`
  Callback for the server response with the input stream from the server.
  `void`
  `removeAllArguments()`
  Removes all arguments
  `void`
  `removeArgument(String key)`
  Removes the given argument from the request
  `void`
  `removeExceptionListener(ActionListener<NetworkEvent> a)`
  Removes the given listener
  `void`
  `removeResponseCodeListener(ActionListener<NetworkEvent> a)`
  Removes the given listener
  `void`
  `removeResponseListener(ActionListener<NetworkEvent> a)`
  Removes the given listener
  `boolean`
  `resume()`
  Called when a previously paused operation now has the networking time to resume.
  `void`
  `retry()`
  Retry the current operation in case of an exception
  `void`
  `setCacheMode(ConnectionRequest.CachingMode cacheMode)`
  There are 5 caching modes:
  `void`
  `setCheckSSLCertificates(boolean checkSSLCertificates)`

  ###### Parameters

  `void`
  `setChunkedStreamingMode(int chunklen)`
  This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is not known in advance.
  `void`
  `setContentType(String contentType)`

  ###### Parameters

  `static void`
  `setCookieHeader(String aCookieHeader)`
  Workaround for https://bugs.php.net/bug.php?id=65633 allowing developers to customize the name of the cookie header to Cookie
  `void`
  `setCookiesEnabled(boolean cookiesEnabled)`

  ###### Parameters

  `static void`
  `setCookiesEnabledDefault(boolean aCookiesEnabledDefault)`

  ###### Parameters

  `static void`
  `setDefaultCacheMode(ConnectionRequest.CachingMode aDefaultCacheMode)`
  The default value for the cacheMode property see `#getCacheMode()`
  `static void`
  `setDefaultFollowRedirects(boolean aDefaultFollowRedirects)`
  Enables/Disables automatic redirects globally and returns the 302 error code, IMPORTANT this feature doesn't work on all platforms and currently doesn't work on iOS which always implicitly redirects
  `static void`
  `setDefaultUserAgent(String aDefaultUserAgent)`

  ###### Parameters

  `void`
  `setDestinationFile(String destinationFile)`
  When set to a none null string saves the response to file system under this file name
  `void`
  `setDestinationStorage(String destinationStorage)`
  When set to a none null string saves the response to storage under this file name
  `void`
  `setDisposeOnCompletion(Dialog disposeOnCompletion)`
  A dialog that will be seamlessly disposed once the given request has been completed
  `void`
  `setDuplicateSupported(boolean duplicateSupported)`
  Indicates whether this connection request supports duplicate entries in the request queue
  `void`
  `setFailSilently(boolean failSilently)`
  Indicates that we are uninterested in error handling
  `void`
  `setFollowRedirects(boolean followRedirects)`
  Enables/Disables automatic redirects globally and returns the 302 error code, IMPORTANT this feature doesn't work on all platforms and currently doesn't work on iOS which always implicitly redirects
  `static void`
  `setHandleErrorCodesInGlobalErrorHandler(boolean aHandleErrorCodesInGlobalErrorHandler)`
  When set to true (the default), the global error handler in `NetworkManager` should receive errors for response code as well
  `void`
  `setHttpMethod(String httpMethod)`
  Sets the http method for the request
  `void`
  `setInsecure(boolean insecure)`
  Turns off checking to make sure that SSL certificate is valid.
  `protected void`
  `setKilled(boolean killed)`

  ###### Parameters

  `protected void`
  `setPaused(boolean paused)`

  ###### Parameters

  `void`
  `setPost(boolean post)`
  Set to true for a post operation and false for a get operation, this will implicitly set the method to post/get respectively (which you can change back by setting the method).
  `void`
  `setPriority(byte priority)`
  The priority of this connection based on the constants in this class
  `void`
  `setReadRequest(boolean readRequest)`

  ###### Parameters

  `void`
  `setReadResponseForErrors(boolean readResponseForErrors)`
  When set to true the read response code will happen even for error codes such as 400 and 500
  `static void`
  `setReadResponseForErrorsDefault(boolean aReadResponseForErrorsDefault)`
  Determines the default value for `#setReadResponseForErrors(boolean)`
  `void`
  `setReadTimeout(int timeout)`
  Sets the read timeout for the connection.
  `void`
  `setRequestBody(Data data)`
  The request body can be used instead of arguments to pass JSON data to a restful request, it can't be used in a get request and will fail if you have arguments.
  `void`
  `setRequestBody(String requestBody)`
  The request body can be used instead of arguments to pass JSON data to a restful request, it can't be used in a get request and will fail if you have arguments.
  `void`
  `setShowOnInit(Dialog showOnInit)`
  This dialog will be shown when this request enters the network queue
  `void`
  `setSilentRetryCount(int silentRetryCount)`
  Indicates the number of times to silently retry a connection that failed before prompting
  `void`
  `setTimeout(int timeout)`
  Indicates the timeout for this connection request
  `void`
  `setUrl(String url)`

  ###### Parameters

  `static void`
  `setUseNativeCookieStore(boolean b)`
  Indicates whether the native Cookie stores should be used
  `void`
  `setUserAgent(String userAgent)`

  ###### Parameters

  `void`
  `setWriteRequest(boolean writeRequest)`

  ###### Parameters

  `protected boolean`
  `shouldAutoCloseResponse()`
  Indicates whether the response stream should be closed automatically by the framework (defaults to true), this might cause an issue if the stream needs to be passed to a separate thread for reading.
  `protected boolean`
  `shouldConvertPostToGetOnRedirect()`
  This mimics the behavior of browsers that convert post operations to get operations when redirecting a request.
  `protected boolean`
  `shouldStop()`
  Returns true if the request is paused or killed, developers should call this method periodically to test whether they should quit the current IO operation immediately
  `protected boolean`
  `shouldWriteUTFAsGetBytes()`
  Returns whether when writing a post body the platform expects something in the form of string.getBytes("UTF-8") or new OutputStreamWriter(os, "UTF-8").
  `protected void`
  `validate()`
  Validates that the request has the required information before being added to the queue e.g.

  ### Methods inherited from class Object

  `clone, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### PRIORITY_CRITICAL

    public static final byte PRIORITY_CRITICAL
    A critical priority request will "push" through the queue to the highest point regardless of anything else and ignoring anything that is not in itself of critical priority. A critical priority will stop any none critical connection in progress
    See Also:
      - Constant Field Values

  - ### PRIORITY_HIGH

    public static final byte PRIORITY_HIGH
    A high priority request is the second highest level, it will act exactly like a critical priority with one difference. It doesn't block another incoming high priority request. E.g. if a high priority request
    See Also:
      - Constant Field Values

  - ### PRIORITY_NORMAL

    public static final byte PRIORITY_NORMAL
    Normal priority executes as usual on the queue
    See Also:
      - Constant Field Values

  - ### PRIORITY_LOW

    public static final byte PRIORITY_LOW
    Low priority requests are mostly background tasks that should still be accomplished though
    See Also:
      - Constant Field Values

  - ### PRIORITY_REDUNDANT

    public static final byte PRIORITY_REDUNDANT
    Redundant elements can be discarded from the queue when paused
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### ConnectionRequest

    public ConnectionRequest()
    Default constructor

  - ### ConnectionRequest

    public ConnectionRequest(String url)

    Construct a connection request to a url

    ###### Parameters

    - `url`: the url

  - ### ConnectionRequest

    public ConnectionRequest(String url, boolean post)

    Construct a connection request to a url

    ###### Parameters

    - `url`: the url

    - `post`: whether the request is a post url or a get URL

- ## Method Details

  - ### getDefaultCacheMode

    public static ConnectionRequest.CachingMode getDefaultCacheMode()

    The default value for the cacheMode property see `#getCacheMode()`

    ###### Returns

    the defaultCacheMode

  - ### setDefaultCacheMode

    public static void setDefaultCacheMode(ConnectionRequest.CachingMode aDefaultCacheMode)

    The default value for the cacheMode property see `#getCacheMode()`

    ###### Parameters

    - `aDefaultCacheMode`: the defaultCacheMode to set

  - ### isReadResponseForErrorsDefault

    public static boolean isReadResponseForErrorsDefault()

    Determines the default value for `#isReadResponseForErrors()`

    ###### Returns

    the readResponseForErrorsDefault

  - ### setReadResponseForErrorsDefault

    public static void setReadResponseForErrorsDefault(boolean aReadResponseForErrorsDefault)

    Determines the default value for `#setReadResponseForErrors(boolean)`

    ###### Parameters

    - `aReadResponseForErrorsDefault`: the readResponseForErrorsDefault to set

  - ### isHandleErrorCodesInGlobalErrorHandler

    public static boolean isHandleErrorCodesInGlobalErrorHandler()

    When set to true (the default), the global error handler in `NetworkManager` should receive errors for response code as well

    ###### Returns

    the handleErrorCodesInGlobalErrorHandler

  - ### setHandleErrorCodesInGlobalErrorHandler

    public static void setHandleErrorCodesInGlobalErrorHandler(boolean aHandleErrorCodesInGlobalErrorHandler)

    When set to true (the default), the global error handler in `NetworkManager` should receive errors for response code as well

    ###### Parameters

    - `aHandleErrorCodesInGlobalErrorHandler`: the handleErrorCodesInGlobalErrorHandler to set

  - ### getCookieHeader

    public static String getCookieHeader()

    Workaround for https://bugs.php.net/bug.php?id=65633 allowing developers to customize the name of the cookie header to Cookie

    ###### Returns

    the cookieHeader

  - ### setCookieHeader

    public static void setCookieHeader(String aCookieHeader)

    Workaround for https://bugs.php.net/bug.php?id=65633 allowing developers to customize the name of the cookie header to Cookie

    ###### Parameters

    - `aCookieHeader`: the cookieHeader to set

  - ### isCookiesEnabledDefault

    public static boolean isCookiesEnabledDefault()

    ###### Returns

    the cookiesEnabledDefault

  - ### setCookiesEnabledDefault

    public static void setCookiesEnabledDefault(boolean aCookiesEnabledDefault)

    ###### Parameters

    - `aCookiesEnabledDefault`: the cookiesEnabledDefault to set

  - ### isDefaultFollowRedirects

    public static boolean isDefaultFollowRedirects()

    Enables/Disables automatic redirects globally and returns the 302 error code, IMPORTANT this feature doesn't work on all platforms and currently doesn't work on iOS which always implicitly redirects

    ###### Returns

    the defaultFollowRedirects

  - ### setDefaultFollowRedirects

    public static void setDefaultFollowRedirects(boolean aDefaultFollowRedirects)

    Enables/Disables automatic redirects globally and returns the 302 error code, IMPORTANT this feature doesn't work on all platforms and currently doesn't work on iOS which always implicitly redirects

    ###### Parameters

    - `aDefaultFollowRedirects`: the defaultFollowRedirects to set

  - ### isReadTimeoutSupported

    public static boolean isReadTimeoutSupported()

    Checks if this platform supports read timeouts.

    ###### Returns

    True if this connection supports read timeouts;

    ###### Since

    7.0

  - ### purgeCacheDirectory

    public static void purgeCacheDirectory() throws IOException
    Purges all locally cached files
    Throws:
      `IOException`

  - ### getDefaultUserAgent

    public static String getDefaultUserAgent()

    ###### Returns

    the defaultUserAgent

  - ### setDefaultUserAgent

    public static void setDefaultUserAgent(String aDefaultUserAgent)

    ###### Parameters

    - `aDefaultUserAgent`: the defaultUserAgent to set

  - ### setUseNativeCookieStore

    public static void setUseNativeCookieStore(boolean b)

    Indicates whether the native Cookie stores should be used

    NOTE: If the platform doesn't support Native Cookie sharing, then this method will have no effect. Use `#isNativeCookieSharingSupported()`} to check if the platform supports native cookie sharing at runtime.

    ###### Parameters

    - `b`: true to enable native cookie stores when applicable

  - ### isNativeCookieSharingSupported

    public static boolean isNativeCookieSharingSupported()

    Checks if the platform supports sharing cookies between the native components (e.g. BrowserComponent) and ConnectionRequests. Currently only iOS and Android support this.

    If the platform does not support native cookie sharing, then methods like `#setUseNativeCookieStore(boolean)` will have no effect.

    ###### Returns

    true if the platform supports native cookie sharing.

    ###### Since

    8.0

  - ### fetchJSON

    public static Map<String,Object> fetchJSON(String url) throws IOException

    Utility method that returns a JSON structure or throws an IOException in case of a failure. This method blocks the EDT legally and can be used synchronously. Notice that this method assumes all JSON data is UTF-8

    ###### Parameters

    - `url`: the URL hosing the JSON

    ###### Returns

    map data

    ###### Throws

    - `IOException`: in case of an error
    Throws:
      `IOException`

  - ### fetchJSONAsync

    public static AsyncResource<Map<String,Object>> fetchJSONAsync(String url)

    Fetches JSON asynchronously.

    ###### Parameters

    - `url`: The URL to fetch.

    ###### Returns

    AsyncResource that will resolve with either an exception or the parsed JSON data.

    ###### Since

    7.0

  - ### getCacheMode

    public ConnectionRequest.CachingMode getCacheMode()

    There are 5 caching modes:

    - `OFF` is the default, meaning no caching.

    - `SMART` means all get requests are cached intelligently and caching is "mostly" seamless.

    - `MANUAL` means that the developer is responsible for the actual caching but the system will not do a request on a resource that's already "fresh".

    - `OFFLINE` will fetch data from the cache and wont try to go to the server. It will generate a 404 error if data isn't available.

    - `OFFLINE_FIRST` works the same way as offline but if data isn't available locally it will try to connect to the server.

    ###### Returns

    the cacheMode

  - ### setCacheMode

    public void setCacheMode(ConnectionRequest.CachingMode cacheMode)

    There are 5 caching modes:

    - `OFF` is the default, meaning no caching.

    - `SMART` means all get requests are cached intelligently and caching is "mostly" seamless.

    - `MANUAL` means that the developer is responsible for the actual caching but the system will not do a request on a resource that's already "fresh".

    - `OFFLINE` will fetch data from the cache and wont try to go to the server. It will generate a 404 error if data isn't available.

    - `OFFLINE_FIRST` works the same way as offline but if data isn't available locally it will try to connect to the server.

    ###### Parameters

    - `cacheMode`: the cacheMode to set

  - ### isCheckSSLCertificates

    public boolean isCheckSSLCertificates()

    ###### Returns

    the checkSSLCertificates

  - ### setCheckSSLCertificates

    public void setCheckSSLCertificates(boolean checkSSLCertificates)

    ###### Parameters

    - `checkSSLCertificates`: the checkSSLCertificates to set

  - ### isInsecure

    public boolean isInsecure()

    Checks if the request is insecure (default false).

    ###### Returns

    True if the request is insecure, i.e. does not check SSL certificate for validity.

    ###### Since

    7.0

  - ### setInsecure

    public void setInsecure(boolean insecure)

    Turns off checking to make sure that SSL certificate is valid.

    ###### Parameters

    - `insecure`

    ###### Since

    7.0

  - ### getResponseData

    public byte[] getResponseData()

    This method will return a valid value for only some of the responses and only after the response was processed

    ###### Returns

    null or the actual data returned

  - ### getHttpMethod

    public String getHttpMethod()

    Returns the http method

    ###### Returns

    the http method of the request

  - ### setHttpMethod

    public void setHttpMethod(String httpMethod)

    Sets the http method for the request

    ###### Parameters

    - `httpMethod`: the http method string

  - ### addRequestHeader

    public void addRequestHeader(String key, String value)

    Adds the given header to the request that will be sent

    ###### Parameters

    - `key`: the header key

    - `value`: the header value

  - ### checkSSLCertificates

    protected void checkSSLCertificates(ConnectionRequest.SSLCertificate[] certificates)

    A callback that can be overridden by subclasses to check the SSL certificates for the server, and kill the connection if they don't pass muster. This can be used for SSL pinning.

    NOTE: This method will only be called if `#isCheckSSLCertificates()` is true and the platform supports SSL certificates (`#canGetSSLCertificates()`.

    WARNING: On iOS it is possible that certificates for a request would not be available even through the platform supports it, and checking certificates are enabled. This could happen if the certificates had been cached by the TLS cache by some network mechanism other than ConnectionRequest (e.g. native code, websockets, etc..). In such cases this method would receive an empty array as a parameter.

    This is called after the SSL handshake, but before any data has been sent.

    ###### Parameters

    - `certificates`: The server's SSL certificates.

    ###### See also

    - #setCheckSSLCertificates(boolean)

    - #isCheckSSLCertificates()

  - ### getReadTimeout

    public int getReadTimeout()

    Gets the read timeout for this connection. This is only used if `#isReadTimeoutSupported()` is true on this platform. Currently Android, Mac Desktop, Windows Desktop, and Simulator supports read timeouts.

    ###### Returns

    The read timeout.

    ###### Since

    7.0

  - ### setReadTimeout

    public void setReadTimeout(int timeout)

    Sets the read timeout for the connection. This is only used if `#isReadTimeoutSupported()` is true on this platform. Currently Android, Mac Desktop, Windows Desktop, and Simulator supports read timeouts.

    ###### Parameters

    - `timeout`: The read timeout. If less than or equal to zero, then there is no timeout.

    ###### See also

    - #isReadTimeoutSupported()

  - ### initConnection

    protected void initConnection(Object connection)

    Invoked to initialize HTTP headers, cookies etc.

    ###### Parameters

    - `connection`: the connection object

  - ### getCachedData

    protected InputStream getCachedData() throws IOException

    This method should be overriden in `CacheMode.MANUAL` to provide offline caching. The default implementation will work as expected in the `CacheMode.SMART` and `CacheMode.OFFLINE_FIRST` modes.

    ###### Returns

    the offline cached data or null/exception if unavailable

    Throws:
      `IOException`

  - ### purgeCache

    public void purgeCache()
    Deletes the cache file if it exists, notice that this will not work for download files

  - ### cacheUnmodified

    protected void cacheUnmodified() throws IOException
    This callback is invoked on a 304 server response indicating the data in the server matches the result we currently have in the cache. This method can be overriden to detect this case
    Throws:
      `IOException`

  - ### cookieReceived

    protected void cookieReceived(Cookie c)

    Callback invoked for every cookie received from the server

    ###### Parameters

    - `c`: the cookie

  - ### cookieSent

    protected void cookieSent(Cookie c)

    Callback invoked for every cookie being sent to the server

    ###### Parameters

    - `c`: the cookie

  - ### initCookieHeader

    protected String initCookieHeader(String cookie)

    Allows subclasses to inject cookies into the request

    ###### Parameters

    - `cookie`: the cookie that the implementation is about to send or null for no cookie

    ###### Returns

    new cookie or the value of cookie

  - ### getResponseCode

    public int getResponseCode()

    Returns the response code for this request, this is only relevant after the request completed and might contain a temporary (e.g. redirect) code while the request is in progress

    ###### Returns

    the response code

  - ### getResposeCode

    public int getResposeCode()

    Returns the response code for this request, this is only relevant after the request completed and might contain a temporary (e.g. redirect) code while the request is in progress

    ###### Returns

    the response code

    ###### Deprecated

    misspelled method name please use getResponseCode

  - ### shouldConvertPostToGetOnRedirect

    protected boolean shouldConvertPostToGetOnRedirect()

    This mimics the behavior of browsers that convert post operations to get operations when redirecting a request.

    ###### Returns

    defaults to true, this case be modified by subclasses

  - ### readHeaders

    protected void readHeaders(Object connection) throws IOException

    Allows reading the headers from the connection by calling the getHeader() method.

    ###### Parameters

    - `connection`: used when invoking getHeader

    ###### Throws

    - `java.io.IOException`: thrown on failure
    Throws:
      `IOException`

  - ### readErrorCodeHeaders

    protected void readErrorCodeHeaders(Object connection) throws IOException

    Allows reading the headers from the connection by calling the getHeader() method when a response that isn't 200 OK is sent.

    ###### Parameters

    - `connection`: used when invoking getHeader

    ###### Throws

    - `java.io.IOException`: thrown on failure
    Throws:
      `IOException`

  - ### getHeader

    protected String getHeader(Object connection, String header) throws IOException

    Returns the HTTP header field for the given connection, this method is only guaranteed to work when invoked from the readHeaders method.

    ###### Parameters

    - `connection`: the connection to the network

    - `header`: the name of the header

    ###### Returns

    the value of the header

    ###### Throws

    - `java.io.IOException`: thrown on failure
    Throws:
      `IOException`

  - ### getHeaders

    protected String[] getHeaders(Object connection, String header) throws IOException

    Returns the HTTP header field for the given connection, this method is only guaranteed to work when invoked from the readHeaders method. Unlike the getHeader method this version works when the same header name is declared multiple times.

    ###### Parameters

    - `connection`: the connection to the network

    - `header`: the name of the header

    ###### Returns

    the value of the header

    ###### Throws

    - `java.io.IOException`: thrown on failure
    Throws:
      `IOException`

  - ### getHeaderFieldNames

    protected String[] getHeaderFieldNames(Object connection) throws IOException

    Returns the HTTP header field names for the given connection, this method is only guaranteed to work when invoked from the readHeaders method.

    ###### Parameters

    - `connection`: the connection to the network

    ###### Returns

    the names of the headers

    ###### Throws

    - `java.io.IOException`: thrown on failure
    Throws:
      `IOException`

  - ### getYield

    protected int getYield()

    Returns the amount of time to yield for other processes, this is an implicit method that automatically generates values for lower priority connections

    ###### Returns

    yield duration or -1 for no yield

  - ### shouldAutoCloseResponse

    protected boolean shouldAutoCloseResponse()

    Indicates whether the response stream should be closed automatically by the framework (defaults to true), this might cause an issue if the stream needs to be passed to a separate thread for reading.

    ###### Returns

    true to close the response stream automatically.

  - ### handleIOException

    protected void handleIOException(IOException err)

    Handles IOException thrown when performing a network operation

    ###### Parameters

    - `err`: the exception thrown

  - ### handleRuntimeException

    protected void handleRuntimeException(RuntimeException err)

    Handles an exception thrown when performing a network operation

    ###### Parameters

    - `err`: the exception thrown

  - ### handleException

    protected void handleException(Exception err)

    Handles an exception thrown when performing a network operation, the default implementation shows a retry dialog.

    ###### Parameters

    - `err`: the exception thrown

  - ### canGetSSLCertificates

    public boolean canGetSSLCertificates()

    Checks to see if the platform supports getting SSL certificates.

    ###### Returns

    True if the platform supports getting SSL certificates.

  - ### getSSLCertificates

    public ConnectionRequest.SSLCertificate[] getSSLCertificates() throws IOException

    Gets the server's SSL certificates for this requests. If this connection request does not have any certificates available, it returns an array of size 0.

    ###### Returns

    The server's SSL certificates. If not available, an empty array.

    Throws:
      `IOException`

  - ### handleErrorResponseCode

    protected void handleErrorResponseCode(int code, String message)

    Handles a server response code that is not 200 and not a redirect (unless redirect handling is disabled)

    ###### Parameters

    - `code`: the response code from the server

    - `message`: the response message from the server

  - ### retry

    public void retry()
    Retry the current operation in case of an exception

  - ### onRedirect

    public boolean onRedirect(String url)

    This is a callback method that been called when there is a redirect. IMPORTANT this feature doesn't work on all platforms and currently doesn't work on iOS which always implicitly redirects

    ###### Parameters

    - `url`: the url to be redirected

    ###### Returns

    true if the implementation would like to handle this by itself

  - ### readResponse

    protected void readResponse(InputStream input) throws IOException

    Callback for the server response with the input stream from the server. This method is invoked on the network thread

    ###### Parameters

    - `input`: the input stream containing the response

    ###### Throws

    - `IOException`: when a read input occurs
    Throws:
      `IOException`

  - ### postResponse

    protected void postResponse()
    A callback method that's invoked on the EDT after the readResponse() method has finished, this is the place where developers should change their Codename One user interface to avoid race conditions that might be triggered by modifications within readResponse. Notice this method is only invoked on a successful response and will not be invoked in case of a failure.

  - ### createRequestURL

    protected String createRequestURL()

    Creates the request URL mostly for a get request

    ###### Returns

    the string of a request

  - ### buildRequestBody

    protected void buildRequestBody(OutputStream os) throws IOException

    Invoked when send body is true, by default sends the request arguments based on "POST" conventions

    ###### Parameters

    - `os`: output stream of the body
    Throws:
      `IOException`

  - ### shouldWriteUTFAsGetBytes

    protected boolean shouldWriteUTFAsGetBytes()
    Returns whether when writing a post body the platform expects something in the form of string.getBytes("UTF-8") or new OutputStreamWriter(os, "UTF-8").

  - ### kill

    public void kill()
    Kills this request if possible

  - ### shouldStop

    protected boolean shouldStop()

    Returns true if the request is paused or killed, developers should call this method periodically to test whether they should quit the current IO operation immediately

    ###### Returns

    true if the request is paused or killed

  - ### isPausable

    protected boolean isPausable()

    Return true from this method if this connection can be paused and resumed later on. A pausable network operation receives a "pause" invocation and is expected to stop network operations as soon as possible. It will later on receive a resume() call and optionally start downloading again.

    ###### Returns

    false by default.

  - ### pause

    public boolean pause()

    Invoked to pause this opeation, this method will only be invoked if isPausable() returns true (its false by default). After this method is invoked current network operations should be stoped as soon as possible for this class.

    ###### Returns

    Returns:
      This method can return false to indicate that there is no need to resume this method since the operation has already been completed or made redundant

  - ### resume

    public boolean resume()

    Called when a previously paused operation now has the networking time to resume. Assuming this method returns true, the network request will be resent to the server and the operation can resume.

    ###### Returns

    Returns:
      This method can return false to indicate that there is no need to resume this method since the operation has already been completed or made redundant

  - ### isPost

    public boolean isPost()

    Returns true for a post operation and false for a get operation

    ###### Returns

    the post

  - ### setPost

    public void setPost(boolean post)

    Set to true for a post operation and false for a get operation, this will implicitly set the method to post/get respectively (which you can change back by setting the method). The main importance of this method is how arguments are added to the request (within the body or in the URL) and so it is important to invoke this method before any argument was added.

    ###### Throws

    - `IllegalStateException`: if invoked after an addArgument call

  - ### addArgument

    public void addArgument(String key, byte[] value)

    Add an argument to the request response

    ###### Parameters

    - `key`: the key of the argument

    - `value`: the value for the argument

    ###### Deprecated

    use the version that accepts a string instead

  - ### removeArgument

    public void removeArgument(String key)

    Removes the given argument from the request

    ###### Parameters

    - `key`: the key of the argument no longer used

  - ### removeAllArguments

    public void removeAllArguments()
    Removes all arguments

  - ### addArgumentNoEncoding

    public void addArgumentNoEncoding(String key, String value)

    Add an argument to the request response without encoding it, this is useful for arguments which are already encoded

    ###### Parameters

    - `key`: the key of the argument

    - `value`: the value for the argument

  - ### addArgumentNoEncoding

    public void addArgumentNoEncoding(String key, String[] value)

    Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same key, notice that this doesn't implicitly encode the value

    ###### Parameters

    - `key`: the key of the argument

    - `value`: the value for the argument

  - ### addArgumentNoEncodingArray

    public void addArgumentNoEncodingArray(String key, String... value)

    Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same key, notice that this doesn't implicitly encode the value

    ###### Parameters

    - `key`: the key of the argument

    - `value`: the value for the argument

  - ### addArgument

    public void addArgument(String key, String value)

    Add an argument to the request response

    ###### Parameters

    - `key`: the key of the argument

    - `value`: the value for the argument

  - ### addArgumentArray

    public void addArgumentArray(String key, String... value)

    Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same key

    ###### Parameters

    - `key`: the key of the argument

    - `value`: the value for the argument

  - ### addArgument

    public void addArgument(String key, String[] value)

    Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same key

    ###### Parameters

    - `key`: the key of the argument

    - `value`: the value for the argument

  - ### addArguments

    public void addArguments(String key, String... value)

    Add an argument to the request response as an array of elements, this will trigger multiple request entries with the same key

    ###### Parameters

    - `key`: the key of the argument

    - `value`: the value for the argument

  - ### getContentType

    public String getContentType()

    ###### Returns

    the contentType

  - ### setContentType

    public void setContentType(String contentType)

    ###### Parameters

    - `contentType`: the contentType to set

  - ### isWriteRequest

    public boolean isWriteRequest()

    ###### Returns

    the writeRequest

  - ### setWriteRequest

    public void setWriteRequest(boolean writeRequest)

    ###### Parameters

    - `writeRequest`: the writeRequest to set

  - ### isReadRequest

    public boolean isReadRequest()

    ###### Returns

    the readRequest

  - ### setReadRequest

    public void setReadRequest(boolean readRequest)

    ###### Parameters

    - `readRequest`: the readRequest to set

  - ### isPaused

    protected boolean isPaused()

    ###### Returns

    the paused

  - ### setPaused

    protected void setPaused(boolean paused)

    ###### Parameters

    - `paused`: the paused to set

  - ### isKilled

    protected boolean isKilled()

    ###### Returns

    the killed

  - ### setKilled

    protected void setKilled(boolean killed)

    ###### Parameters

    - `killed`: the killed to set

  - ### getPriority

    public byte getPriority()

    The priority of this connection based on the constants in this class

    ###### Returns

    the priority

  - ### setPriority

    public void setPriority(byte priority)

    The priority of this connection based on the constants in this class

    ###### Parameters

    - `priority`: the priority to set

  - ### getUserAgent

    public String getUserAgent()

    ###### Returns

    the userAgent

  - ### setUserAgent

    public void setUserAgent(String userAgent)

    ###### Parameters

    - `userAgent`: the userAgent to set

  - ### isFollowRedirects

    public boolean isFollowRedirects()

    Enables/Disables automatic redirects globally and returns the 302 error code, IMPORTANT this feature doesn't work on all platforms and currently doesn't work on iOS which always implicitly redirects

    ###### Returns

    the followRedirects

  - ### setFollowRedirects

    public void setFollowRedirects(boolean followRedirects)

    Enables/Disables automatic redirects globally and returns the 302 error code, IMPORTANT this feature doesn't work on all platforms and currently doesn't work on iOS which always implicitly redirects

    ###### Parameters

    - `followRedirects`: the followRedirects to set

  - ### getTimeout

    public int getTimeout()

    Indicates the timeout for this connection request

    ###### Returns

    the timeout

  - ### setTimeout

    public void setTimeout(int timeout)

    Indicates the timeout for this connection request

    ###### Parameters

    - `timeout`: the timeout to set

  - ### getContentLength

    public int getContentLength()

    Returns the content length header value

    ###### Returns

    the content length

  - ### ioStreamUpdate

    public void ioStreamUpdate(Object source, int bytes)

    Indicates the number of bytes that were read/written to/from the source stream

    ###### Parameters

    - `source`: the source stream which can be either an input stream or an output stream

    - `bytes`: the number of bytes read or written

    Specified by:
      `ioStreamUpdate` in interface `IOProgressListener`

  - ### getUrl

    public String getUrl()

    ###### Returns

    the url

  - ### setUrl

    public void setUrl(String url)

    ###### Parameters

    - `url`: the url to set

  - ### addResponseListener

    public void addResponseListener(ActionListener<NetworkEvent> a)

    Adds a listener that would be notified on the CodenameOne thread of a response from the server. This event is specific to the connection request type and its firing will change based on how the connection request is read/processed

    ###### Parameters

    - `a`: listener

  - ### removeResponseListener

    public void removeResponseListener(ActionListener<NetworkEvent> a)

    Removes the given listener

    ###### Parameters

    - `a`: listener

  - ### addResponseCodeListener

    public void addResponseCodeListener(ActionListener<NetworkEvent> a)

    Adds a listener that would be notified on the CodenameOne thread of a response code that is not a 200 (OK) or 301/2 (redirect) response code.

    ###### Parameters

    - `a`: listener

  - ### addExceptionListener

    public void addExceptionListener(ActionListener<NetworkEvent> a)

    Adds a listener that would be notified on the CodenameOne thread of an exception in this connection request

    ###### Parameters

    - `a`: listener

  - ### removeResponseCodeListener

    public void removeResponseCodeListener(ActionListener<NetworkEvent> a)

    Removes the given listener

    ###### Parameters

    - `a`: listener

  - ### removeExceptionListener

    public void removeExceptionListener(ActionListener<NetworkEvent> a)

    Removes the given listener

    ###### Parameters

    - `a`: listener

  - ### hasResponseListeners

    protected boolean hasResponseListeners()

    Returns true if someone is listening to action response events, this is useful so we can decide whether to bother collecting data for an event in some cases since building the event object might be memory/CPU intensive.

    ###### Returns

    true or false

  - ### fireResponseListener

    protected void fireResponseListener(ActionEvent ev)

    Fires the response event to the listeners on this connection

    ###### Parameters

    - `ev`: the event to fire

  - ### isDuplicateSupported

    public boolean isDuplicateSupported()

    Indicates whether this connection request supports duplicate entries in the request queue

    ###### Returns

    the duplicateSupported value

  - ### setDuplicateSupported

    public void setDuplicateSupported(boolean duplicateSupported)

    Indicates whether this connection request supports duplicate entries in the request queue

    ###### Parameters

    - `duplicateSupported`: the duplicateSupported to set

  - ### hashCode

    public int hashCode()
    Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable. The general contract of hashCode is: Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result. It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables. As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object o)
    Indicates whether some other object is "equal to" this one. The equals method implements an equivalence relation: It is reflexive: for any reference value x, x.equals(x) should return true. It is symmetric: for any reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. It is consistent: for any reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the object is modified. For any non-null reference value x, x.equals(null) should return false. The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any reference values x and y, this method returns true if and only if x and y refer to the same object (x==y has the value true).
    Overrides:
      `equals` in class `Object`

  - ### validate

    protected void validate()
    Validates that the request has the required information before being added to the queue e.g. checks if the URL is null. This method should throw an IllegalStateException for a case where one of the values required for this connection request is missing. This method can be overriden by subclasses to add additional tests. It is usefull to do tests here since the exception will be thrown immediately when invoking addToQueue which is more intuitive to debug than the alternative.

  - ### getDisposeOnCompletion

    public Dialog getDisposeOnCompletion()

    A dialog that will be seamlessly disposed once the given request has been completed

    ###### Returns

    the disposeOnCompletion

  - ### setDisposeOnCompletion

    public void setDisposeOnCompletion(Dialog disposeOnCompletion)

    A dialog that will be seamlessly disposed once the given request has been completed

    ###### Parameters

    - `disposeOnCompletion`: the disposeOnCompletion to set

  - ### getShowOnInit

    public Dialog getShowOnInit()

    This dialog will be shown when this request enters the network queue

    ###### Returns

    the showOnInit

  - ### setShowOnInit

    public void setShowOnInit(Dialog showOnInit)

    This dialog will be shown when this request enters the network queue

    ###### Parameters

    - `showOnInit`: the showOnInit to set

  - ### getSilentRetryCount

    public int getSilentRetryCount()

    Indicates the number of times to silently retry a connection that failed before prompting

    ###### Returns

    the silentRetryCount

  - ### setSilentRetryCount

    public void setSilentRetryCount(int silentRetryCount)

    Indicates the number of times to silently retry a connection that failed before prompting

    ###### Parameters

    - `silentRetryCount`: the silentRetryCount to set

  - ### isFailSilently

    public boolean isFailSilently()

    Indicates that we are uninterested in error handling

    ###### Returns

    the failSilently

  - ### setFailSilently

    public void setFailSilently(boolean failSilently)

    Indicates that we are uninterested in error handling

    ###### Parameters

    - `failSilently`: the failSilently to set

  - ### isReadResponseForErrors

    public boolean isReadResponseForErrors()

    When set to true the read response code will happen even for error codes such as 400 and 500

    ###### Returns

    the readResponseForErrors

  - ### setReadResponseForErrors

    public void setReadResponseForErrors(boolean readResponseForErrors)

    When set to true the read response code will happen even for error codes such as 400 and 500

    ###### Parameters

    - `readResponseForErrors`: the readResponseForErrors to set

  - ### getResponseContentType

    public String getResponseContentType()

    Returns the content type from the response headers

    ###### Returns

    the content type

  - ### isRedirecting

    public boolean isRedirecting()

    Returns true if this request is been redirected to a different url

    ###### Returns

    true if redirecting

  - ### getDestinationFile

    public String getDestinationFile()

    When set to a none null string saves the response to file system under this file name

    ###### Returns

    the destinationFile

  - ### setDestinationFile

    public void setDestinationFile(String destinationFile)

    When set to a none null string saves the response to file system under this file name

    ###### Parameters

    - `destinationFile`: the destinationFile to set

  - ### getDestinationStorage

    public String getDestinationStorage()

    When set to a none null string saves the response to storage under this file name

    ###### Returns

    the destinationStorage

  - ### setDestinationStorage

    public void setDestinationStorage(String destinationStorage)

    When set to a none null string saves the response to storage under this file name

    ###### Parameters

    - `destinationStorage`: the destinationStorage to set

  - ### isCookiesEnabled

    public boolean isCookiesEnabled()

    ###### Returns

    the cookiesEnabled

  - ### setCookiesEnabled

    public void setCookiesEnabled(boolean cookiesEnabled)

    ###### Parameters

    - `cookiesEnabled`: the cookiesEnabled to set

  - ### setChunkedStreamingMode

    public void setChunkedStreamingMode(int chunklen)

    This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is not known in advance. In this mode, chunked transfer encoding is used to send the request body. Note, not all HTTP servers support this mode. This mode is supported on Android and the Desktop ports.

    ###### Parameters

    - `chunklen`: @param chunklen The number of bytes to write in each chunk. If chunklen is zero a default value will be used.

  - ### downloadImageToStorage

    public void downloadImageToStorage(String storageFile, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail, boolean useCache)

    Downloads an image to a specified storage file asynchronously and calls the onSuccessCallback with the resulting image. If useCache is true, then this will first try to load the image from Storage if it exists.

    ###### Parameters

    - `storageFile`: The storage file where the file should be saved.

    - `onSuccess`: Callback called if the image is successfully loaded.

    - `onFail`: Callback called if we fail to load the image.

    - `useCache`: If true, then this will first check the storage to see if the image is already downloaded.

    ###### Since

    3.4

  - ### downloadImageToStorage

    public AsyncResource<Image> downloadImageToStorage(String storageFile)

    Downloads an image to a specified storage file asynchronously returning an AsyncResource that resolves to the resulting image..

    ###### Parameters

    - `storageFile`: The storage file where the file should be saved.

    ###### Returns

    AsyncResource that will resolve to the loaded image.

    ###### Since

    7.0

  - ### downloadImageToStorage

    public AsyncResource<Image> downloadImageToStorage(String storageFile, boolean useCache)

    Downloads an image to a specified storage file asynchronously returning an AsyncResource that resolves to the resulting image.. If useCache is true, then this will first try to load the image from Storage if it exists.

    ###### Parameters

    - `storageFile`: The storage file where the file should be saved.

    - `useCache`: If true, then this will first check the storage to see if the image is already downloaded.

    ###### Returns

    AsyncResource that will resolve to the loaded image.

    ###### Since

    7.0

  - ### downloadImageToStorage

    public void downloadImageToStorage(String storageFile, SuccessCallback<Image> onSuccess, boolean useCache)

    Downloads an image to a specified storage file asynchronously and calls the onSuccessCallback with the resulting image. If useCache is true, then this will first try to load the image from Storage if it exists.

    ###### Parameters

    - `storageFile`: The storage file where the file should be saved.

    - `onSuccess`: Callback called if the image is successfully loaded.

    - `useCache`: If true, then this will first check the storage to see if the image is already downloaded.

    ###### Since

    3.4

  - ### downloadImageToStorage

    public void downloadImageToStorage(String storageFile, SuccessCallback<Image> onSuccess)

    Downloads an image to a specified storage file asynchronously and calls the onSuccessCallback with the resulting image. This will first try to load the image from Storage if it exists.

    ###### Parameters

    - `storageFile`: The storage file where the file should be saved.

    - `onSuccess`: Callback called if the image is successfully loaded.

    ###### Since

    3.4

  - ### downloadImageToStorage

    public void downloadImageToStorage(String storageFile, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail)

    Downloads an image to a specified storage file asynchronously and calls the onSuccessCallback with the resulting image. This will first try to load the image from Storage if it exists.

    ###### Parameters

    - `storageFile`: The storage file where the file should be saved.

    - `onSuccess`: Callback called if the image is successfully loaded.

    ###### Since

    3.4

  - ### downloadImageToFileSystem

    public AsyncResource<Image> downloadImageToFileSystem(String file, boolean useCache)

    Downloads an image to a the file system asynchronously returning an AsyncResource object that resolves to the loaded image.. If useCache is true, then this will first try to load the image from Storage if it exists.

    ###### Parameters

    - `file`: The storage file where the file should be saved.

    - `useCache`: If true, then this will first check the storage to see if the image is already downloaded.

    ###### Returns

    AsyncResource resolving to the downloaded image.

    ###### Since

    7.0

  - ### downloadImageToFileSystem

    public AsyncResource<Image> downloadImageToFileSystem(String file)

    Downloads an image to the file system asynchronously returning an AsyncResource object that resolves to the loaded image.. If useCache is true, then this will first try to load the image from Storage if it exists. This is a wrapper around `boolean)` with true as the 2nd parameter.

    ###### Parameters

    - `file`: The storage file where the file should be saved.

    ###### Returns

    AsyncResource resolving to the downloaded image.

    ###### Since

    7.0

  - ### downloadImageToFileSystem

    public void downloadImageToFileSystem(String file, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail, boolean useCache)

    Downloads an image to a the file system asynchronously and calls the onSuccessCallback with the resulting image. If useCache is true, then this will first try to load the image from Storage if it exists.

    ###### Parameters

    - `file`: The storage file where the file should be saved.

    - `onSuccess`: Callback called if the image is successfully loaded.

    - `onFail`: Callback called if we fail to load the image.

    - `useCache`: If true, then this will first check the storage to see if the image is already downloaded.

    ###### Since

    3.4

  - ### downloadImageToFileSystem

    public void downloadImageToFileSystem(String file, SuccessCallback<Image> onSuccess, boolean useCache)

    Downloads an image to a the file system asynchronously and calls the onSuccessCallback with the resulting image. If useCache is true, then this will first try to load the image from Storage if it exists.

    ###### Parameters

    - `file`: The storage file where the file should be saved.

    - `onSuccess`: Callback called if the image is successfully loaded.

    - `useCache`: If true, then this will first check the storage to see if the image is already downloaded.

    ###### Since

    3.4

  - ### downloadImageToFileSystem

    public void downloadImageToFileSystem(String file, SuccessCallback<Image> onSuccess)

    Downloads an image to a the file system asynchronously and calls the onSuccessCallback with the resulting image. This will first try to load the image from Storage if it exists.

    ###### Parameters

    - `file`: The storage file where the file should be saved.

    - `onSuccess`: Callback called if the image is successfully loaded.

    ###### Since

    3.4

  - ### downloadImageToFileSystem

    public void downloadImageToFileSystem(String file, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail)

    Downloads an image to a the file system asynchronously and calls the onSuccessCallback with the resulting image. This will first try to load the image from Storage if it exists.

    ###### Parameters

    - `file`: The storage file where the file should be saved.

    - `onSuccess`: Callback called if the image is successfully loaded.

    - `onFail`: Callback called if the image fails to load.

    ###### Since

    3.4

  - ### getRequestBody

    public String getRequestBody()

    The request body can be used instead of arguments to pass JSON data to a restful request, it can't be used in a get request and will fail if you have arguments

    ###### Returns

    the requestBody

  - ### setRequestBody

    public void setRequestBody(String requestBody)

    The request body can be used instead of arguments to pass JSON data to a restful request, it can't be used in a get request and will fail if you have arguments.

    Notice that invoking this method blocks the `#buildRequestBody(java.io.OutputStream)` method callback.

    ###### Parameters

    - `requestBody`: a string to pass in the post body

  - ### setRequestBody

    public void setRequestBody(Data data)

    The request body can be used instead of arguments to pass JSON data to a restful request, it can't be used in a get request and will fail if you have arguments.

    Notice that invoking this method blocks the `#buildRequestBody(java.io.OutputStream)` method callback.

    ###### Parameters

    - `data`: a data to pass in the post body

    ###### Since

    7.0

  - ### getRequestBodyData

    public Data getRequestBodyData()

    The request body can be used instead of arguments to pass JSON data to a restful request, it can't be used in a get request and will fail if you have arguments

    ###### Returns

    the requestBody

    ###### Since

    7.0

  - ### getResponseErrorMessage

    public String getResponseErrorMessage()

    Returns error message associated with an error response code

    ###### Returns

    the system error message