Example #1
0
 public void send(final String content, final Request requestType) throws IOException {
   if (uaContext.isRequestPermitted(requestType)) {
     try {
       final Map<String, String> requestedHeadersCopy = new HashMap<>(requestedHeaders);
       final RequestHandler rhandler =
           new LocalRequestHandler(
               this.requestURL, this.requestMethod, content, uaContext, requestedHeadersCopy);
       this.currentRequestHandler = rhandler;
       try {
         // TODO: Username and password support
         if (this.isAsynchronous) {
           RequestEngine.getInstance().scheduleRequest(rhandler);
         } else {
           RequestEngine.getInstance().inlineRequest(rhandler);
         }
       } finally {
         this.currentRequestHandler = null;
       }
     } catch (final Exception err) {
       logger.log(Level.SEVERE, "open()", err);
     }
   } else {
     abort();
   }
 }
 /*
  * (non-Javadoc)
  * @see org.lobobrowser.ua.NetworkRequest#abort()
  */
 @Override
 public void abort() {
   RequestHandler rhToDelete = this.currentRequestHandler;
   if (rhToDelete != null) {
     RequestEngine.getInstance().cancelRequest(rhToDelete);
   }
 }
Example #3
0
  public void abort() {
    this.readyState = NetworkRequest.STATE_ABORTED;
    this.READY_STATE_CHANGE.fireEvent(new NetworkRequestEvent(this, this.readyState));

    final RequestHandler rhToDelete = this.currentRequestHandler;
    if (rhToDelete != null) {
      RequestEngine.getInstance().cancelRequest(rhToDelete);
    }
  }
 /*
  * (non-Javadoc)
  * @see org.lobobrowser.ua.NetworkRequest#send(java.lang.String)
  */
 @Override
 public void send(String content) throws IOException {
   try {
     RequestHandler rhandler =
         new LocalRequestHandler(new URL(req.getUrl()), req.getMethod().name(), content);
     this.currentRequestHandler = rhandler;
     try {
       // TODO: Username and password support
       if (this.isAsynchronous) {
         RequestEngine.getInstance().scheduleRequest(rhandler);
       } else {
         RequestEngine.getInstance().inlineRequest(rhandler);
       }
     } finally {
       this.currentRequestHandler = null;
     }
   } catch (Exception err) {
     logger.log(Level.SEVERE, "open()", err);
   }
 }
 /*
  * (non-Javadoc)
  *
  * @see org.lobobrowser.ua.NavigatorWindow#stop()
  */
 @Override
 public boolean stop() {
   org.lobobrowser.request.RequestEngine.getInstance().cancelAllRequests();
   return true;
 }