public HttpConnection getResource(RequestedResource resource, BrowserContent referrer) {
   if ((resource != null) && (resource.getUrl() != null) && !resource.isCacheOnly()) {
     String url = resource.getUrl().trim();
     if ((referrer == null) || (ConnectionManager.isInternal(url, resource))) {
       return ConnectionManager.getUnmanagedConnection(url, resource.getRequestHeaders(), null);
     } else {
       SecondaryResourceFetchThread.enqueue(resource, referrer);
     }
     url = null;
   }
   return null;
 }
  public void run() {

    while (true) {

      if (_done) {

        // check if we are done requesting images
        synchronized (_syncObject) {
          synchronized (_imageQueue) {
            if (_imageQueue.size() == 0) {
              _currentThread = null;
              break;
            }
          }
        }
      }

      RequestedResource resource = null;

      // request next image
      synchronized (_imageQueue) {
        if (_imageQueue.size() > 0) {
          resource = (RequestedResource) _imageQueue.elementAt(0);
          _imageQueue.removeElementAt(0);
        }
      }

      if (resource != null) {

        HttpConnection connection =
            Utilities.makeConnection(resource.getUrl(), resource.getRequestHeaders(), null);
        resource.setHttpConnection(connection);

        // signal to the browser field that resource is ready
        if (_browserField != null) {
          _browserField.resourceReady(resource);
        }
      }
    }
  }
Exemplo n.º 3
0
  public HttpConnection getResource(RequestedResource resource, BrowserContent referrer) {

    if (resource == null) return null;

    String url = resource.getUrl();
    if (url == null || url.endsWith("/favicon.ico")) return null;

    try {
      if (referrer == null || URI.isLocalData(url) || !m_bLoadImageAsync) {
        boolean bLocalHost = RhodesApp.getInstance().isRhodesAppUrl(url);
        if (bLocalHost && m_connResource != null) {
          com.rho.net.RhoConnection rhoConn =
              (com.rho.net.RhoConnection)
                  ((com.rho.net.bb.NativeBBHttpConnection) m_connResource).getNativeConnection();
          rhoConn.resetUrl(url);

          Utilities.makeConnection(url, resource.getRequestHeaders(), null, m_connResource);
          return m_connResource;
        } else {
          HttpConnection connection =
              Utilities.makeConnection(url, resource.getRequestHeaders(), null, null);
          // if (bLocalHost)
          //	m_connResource = connection;
          return connection;
        }
      } else {
        SecondaryResourceFetchThread.enqueue(resource, referrer);
      }
    } catch (Exception exc) {
      LOG.ERROR("getResource failed.", exc);
    }

    return null;

    /*
     // check if this is cache-only request
     if (resource.isCacheOnly()) {
         // no cache support
         return null;
     }

     String url = resource.getUrl();

     if (url == null) {
         return null;
     }

     try{
      // if referrer is null we must return the connection
      if (referrer == null) {
          HttpConnection connection = Utilities.makeConnection(url, resource.getRequestHeaders(), null);
          return connection;

      } else
      {
    if ( URI.isLocalHost(url) || URI.isLocalData(url))
    {
              HttpConnection connection = Utilities.makeConnection(url, resource.getRequestHeaders(), null);
              return connection;
    }else
    {
           // if referrer is provided we can set up the connection on a separate thread
           SecondaryResourceFetchThread.enqueue(resource, referrer);
    }
      }
     }catch(Exception exc)
     {
     	LOG.ERROR("getResource failed.", exc);
     }

     return null;*/
  }