public String getStatusText() { try { final LocalResponse lr = this.localResponse; return lr == null ? null : lr.getStatusText(); } catch (final java.io.IOException ioe) { return null; } }
public int getStatus() { try { final LocalResponse lr = this.localResponse; return lr == null ? NetworkRequest.STATE_UNINITIALIZED : lr.getStatus(); } catch (final java.io.IOException ioe) { return 0; } }
/* * (non-Javadoc) * @see org.lobobrowser.ua.NetworkRequest#getStatusText() */ @Override public String getStatusText() { try { LocalResponse lr = this.localResponse; return lr == null ? null : lr.getStatusText(); } catch (IOException ioe) { return null; } }
public Image getResponseImage() { final LocalResponse lr = this.localResponse; return lr == null ? null : lr.getResponseImage(); }
public Document getResponseXML() { final LocalResponse lr = this.localResponse; return lr == null ? null : lr.getResponseXML(); }
public String getResponseText() { final LocalResponse lr = this.localResponse; return lr == null ? null : lr.getResponseText(); }
private void setResponse(final ClientletResponse response) { final Runnable runnable = () -> { if (response.isFromCache()) { final Object cachedResponse = response.getTransientCachedObject(); if (cachedResponse instanceof CacheableResponse) { // It can be of a different type. final CacheableResponse cr = (CacheableResponse) cachedResponse; this.changeReadyState(NetworkRequest.STATE_LOADING); this.localResponse = cr.newLocalResponse(response); this.changeReadyState(NetworkRequest.STATE_LOADED); this.changeReadyState(NetworkRequest.STATE_INTERACTIVE); this.changeReadyState(NetworkRequest.STATE_COMPLETE); return; } } try { this.changeReadyState(NetworkRequest.STATE_LOADING); final LocalResponse newResponse = new LocalResponse(response); this.localResponse = newResponse; this.changeReadyState(NetworkRequest.STATE_LOADED); final int cl = response.getContentLength(); final InputStream in = response.getInputStream(); final int bufferSize = cl == -1 ? 8192 : Math.min(cl, 8192); final byte[] buffer = new byte[bufferSize]; int numRead; int readSoFar = 0; boolean firstTime = true; final ClientletContext threadContext = ClientletAccess.getCurrentClientletContext(); NavigatorProgressEvent prevProgress = null; if (threadContext != null) { prevProgress = threadContext.getProgressEvent(); } try { long lastProgress = 0; while ((numRead = in.read(buffer)) != -1) { if (numRead == 0) { if (logger.isLoggable(Level.INFO)) { logger.info("setResponse(): Read zero bytes from " + response.getResponseURL()); } break; } readSoFar += numRead; if (threadContext != null) { final long currentTime = System.currentTimeMillis(); if ((currentTime - lastProgress) > 500) { lastProgress = currentTime; threadContext.setProgressEvent( ProgressType.CONTENT_LOADING, readSoFar, cl, response.getResponseURL()); } } newResponse.writeBytes(buffer, 0, numRead); if (firstTime) { firstTime = false; this.changeReadyState(NetworkRequest.STATE_INTERACTIVE); } } } finally { if (threadContext != null) { threadContext.setProgressEvent(prevProgress); } } newResponse.setComplete(true); // The following should return non-null if the response is complete. final CacheableResponse cacheable = newResponse.getCacheableResponse(); if (cacheable != null) { response.setNewTransientCachedObject(cacheable, cacheable.getEstimatedSize()); } this.changeReadyState(NetworkRequest.STATE_COMPLETE); } catch (final IOException ioe) { logger.log(Level.WARNING, "setResponse()", ioe); this.localResponse = null; this.changeReadyState(NetworkRequest.STATE_COMPLETE); } }; if (isAsynchronous) { // TODO: Use the JS queue to schedule this runnable.run(); } else { runnable.run(); } }
public String getResponseHeader(final String headerName) { final LocalResponse lr = this.localResponse; return lr == null ? null : lr.getResponseHeader(headerName); }
public String getAllResponseHeaders(final List<String> excludedHeadersLowerCase) { final LocalResponse lr = this.localResponse; return lr == null ? null : lr.getAllResponseHeaders(excludedHeadersLowerCase); }
public byte[] getResponseBytes() { final LocalResponse lr = this.localResponse; return lr == null ? null : lr.getResponseBytes(); }
/* * (non-Javadoc) * @see org.lobobrowser.ua.NetworkRequest#getResponseText() */ @Override public String getResponseText() { LocalResponse lr = this.localResponse; return lr == null ? null : lr.getResponseText(); }
/* * (non-Javadoc) * @see org.lobobrowser.ua.NetworkRequest#getResponseHeader(java.lang.String) */ @Override public String getResponseHeader(String headerName) { LocalResponse lr = this.localResponse; return lr == null ? null : lr.getResponseHeader(headerName); }
/* * (non-Javadoc) * @see org.lobobrowser.ua.NetworkRequest#getAllResponseHeaders() */ @Override public String getAllResponseHeaders() { LocalResponse lr = this.localResponse; return lr == null ? null : lr.getAllResponseHeaders(); }
/* * (non-Javadoc) * @see org.lobobrowser.ua.NetworkRequest#getResponseBytes() */ @Override public byte[] getResponseBytes() { LocalResponse lr = this.localResponse; return lr == null ? null : lr.getResponseBytes(); }
/* * (non-Javadoc) * @see org.lobobrowser.ua.NetworkRequest#getResponseImage() */ @Override public Image getResponseImage() { LocalResponse lr = this.localResponse; return lr == null ? null : lr.getResponseImage(); }
/* * (non-Javadoc) * @see org.lobobrowser.ua.NetworkRequest#getResponseXML() */ @Override public Document getResponseXML() { LocalResponse lr = this.localResponse; return lr == null ? null : lr.getResponseXML(); }