# Class AsyncDocumentRequestHandlerImpl

java.lang.Object
com.codename1.ui.html.DefaultDocumentRequestHandler
com.codename1.ui.html.AsyncDocumentRequestHandlerImpl

All Implemented Interfaces:
  `AsyncDocumentRequestHandler, DocumentRequestHandler`

public class AsyncDocumentRequestHandlerImpl extends DefaultDocumentRequestHandler
Implementation of the HTML components document request handler to allow simple HTML support in CodenameOne.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final Object`
  `LOCK`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AsyncDocumentRequestHandlerImpl()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected ConnectionRequest`
  `createConnectionRequest(DocumentInfo docInfo, IOCallback callback, Object[] response)`
  `InputStream`
  `resourceRequested(DocumentInfo docInfo)`
  Implementations should return the document in the requested url as an InputStream This is triggered only for the main document requested and not for its resources.
  `void`
  `resourceRequestedAsync(DocumentInfo docInfo, IOCallback callback)`
  This method is called by HTMLComponent when a resource is requested asynchronously.

  ### Methods inherited from class DefaultDocumentRequestHandler

  `getResFile, isTrackVisitedURLs, setResFile, setTrackVisitedURLs, visitingURL, wasURLVisited`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### LOCK

    protected static final Object LOCK

- ## Constructor Details

  - ### AsyncDocumentRequestHandlerImpl

    public AsyncDocumentRequestHandlerImpl()

- ## Method Details

  - ### resourceRequestedAsync

    public void resourceRequestedAsync(DocumentInfo docInfo, IOCallback callback)

    This method is called by HTMLComponent when a resource is requested asynchronously. This method should return immediately and start a process of fetching the requested resource on another thread. When the resource was fetched, the HTMLComponent.streamReady should be called.

    ###### Parameters

    - `docInfo`: A DocumentInfo object representing the requested URL and its attributes

    - `callback`: The HTMLComponent that should be called back when the stream was fetched.

    Specified by:
      `resourceRequestedAsync` in interface `AsyncDocumentRequestHandler`
    Overrides:
      `resourceRequestedAsync` in class `DefaultDocumentRequestHandler`

  - ### resourceRequested

    public InputStream resourceRequested(DocumentInfo docInfo)

    Implementations should return the document in the requested url as an InputStream This is triggered only for the main document requested and not for its resources.

    ###### Parameters

    - `docInfo`: A DocumentInfo object representing the requested URL and its attributes

    ###### Returns

    the document at the URL as an InputStream

    Specified by:
      `resourceRequested` in interface `DocumentRequestHandler`
    Overrides:
      `resourceRequested` in class `DefaultDocumentRequestHandler`

  - ### createConnectionRequest

    protected ConnectionRequest createConnectionRequest(DocumentInfo docInfo, IOCallback callback, Object[] response)