public NonFinalResponseListener(HttpExchange exchange) { _exchange=exchange; _next=exchange.getEventListener(); }
public SecurityListener(HttpDestination destination, HttpExchange ex) { // Start of sending events through to the wrapped listener // Next decision point is the onResponseStatus super(ex.getEventListener(),true); _destination=destination; _exchange=ex; }
public RedirectListener(HttpDestination destination, HttpExchange ex) { // Start of sending events through to the wrapped listener // Next decision point is the onResponseStatus super(ex.getEventListener(),true); _destination = destination; _exchange = ex; }
public NtlmListener( final HttpDestination destination, final HttpExchange ex ) { // Start of sending events through to the wrapped listener // Next decision point is the onResponseStatus super( ex.getEventListener(), true ); _authTypes = new HashSet<String>(); _exchange = ex; }
@Override public void content(Buffer ref) throws IOException { HttpExchange exchange = _exchange; if (exchange!=null) exchange.getEventListener().onResponseContent(ref); }
private boolean setStatusExpired(int newStatus, int oldStatus) { boolean set; if (set = _status.compareAndSet(oldStatus,newStatus)) getEventListener().onExpire(); return set; }
public WebdavListener(HttpDestination destination, HttpExchange ex) { // Start of sending events through to the wrapped listener // Next decision point is the onResponseStatus super(ex.getEventListener(),true); _destination=destination; _exchange=ex; // We'll only enable webdav if this is a PUT request if ( HttpMethods.PUT.equalsIgnoreCase( _exchange.getMethod() ) ) { _webdavEnabled = true; } }
public void onException(Throwable throwable) { synchronized (this) { _pendingConnections--; if (_exchanges.size() > 0) { HttpExchange ex = _exchanges.remove(0); if (ex.setStatus(HttpExchange.STATUS_EXCEPTED)) ex.getEventListener().onException(throwable); } } }
@Override protected void onExpire() { HttpExchange exchange = null; synchronized (HttpDestination.this) { if (!_exchanges.isEmpty()) exchange = _exchanges.remove(0); } if (exchange != null && exchange.setStatus(STATUS_EXPIRED)) exchange.getEventListener().onExpire(); } }
@Override protected void onException(Throwable x) { HttpExchange exchange = null; synchronized (HttpDestination.this) { if (!_exchanges.isEmpty()) exchange = _exchanges.remove(0); } if (exchange != null && exchange.setStatus(STATUS_EXCEPTED)) exchange.getEventListener().onException(x); }
public void resend(HttpExchange ex) throws IOException { ex.getEventListener().onRetry(); ex.reset(); doSend(ex); }
@Override public void parsedHeader(Buffer name, Buffer value) throws IOException { HttpExchange exchange = _exchange; if (exchange!=null) { if (HttpHeaders.CACHE.getOrdinal(name) == HttpHeaders.CONNECTION_ORDINAL) { _connectionHeader = HttpHeaderValues.CACHE.lookup(value); } exchange.getEventListener().onResponseHeader(name,value); } }
ex.getEventListener().onConnectionFailed(throwable);
@Override public void earlyEOF() { HttpExchange exchange = _exchange; if (exchange!=null) { if (!exchange.isDone()) { if (exchange.setStatus(HttpExchange.STATUS_EXCEPTED)) exchange.getEventListener().onException(new EofException("early EOF")); } } } }
case STATUS_WAITING_FOR_RESPONSE: if (set = _status.compareAndSet(oldStatus,newStatus)) getEventListener().onRequestCommitted(); break; case STATUS_CANCELLING: getEventListener().onResponseHeaderComplete(); break; case STATUS_CANCELLING: getEventListener().onResponseComplete(); break; case STATUS_CANCELLING: getEventListener().onRequestCommitted(); getEventListener().onRequestCommitted(); break; case STATUS_PARSING_CONTENT: if (set = _status.compareAndSet(oldStatus,STATUS_SENDING_PARSING_CONTENT)) getEventListener().onResponseHeaderComplete(); break; case STATUS_CANCELLING: getEventListener().onRequestCommitted(); break; case STATUS_COMPLETED: if (set = _status.compareAndSet(oldStatus,STATUS_SENDING_COMPLETED)) getEventListener().onResponseComplete();
@Override public void startResponse(Buffer version, int status, Buffer reason) throws IOException { HttpExchange exchange = _exchange; if (exchange==null) { LOG.warn("No exchange for response"); _endp.close(); return; } switch(status) { case HttpStatus.CONTINUE_100: case HttpStatus.PROCESSING_102: // TODO check if appropriate expect was sent in the request. exchange.setEventListener(new NonFinalResponseListener(exchange)); break; case HttpStatus.OK_200: // handle special case for CONNECT 200 responses if (HttpMethods.CONNECT.equalsIgnoreCase(exchange.getMethod())) _parser.setHeadResponse(true); break; } _http11 = HttpVersions.HTTP_1_1_BUFFER.equals(version); _status=status; exchange.getEventListener().onResponseStatus(version,status,reason); exchange.setStatus(HttpExchange.STATUS_PARSING_HEADERS); }
_exchange.getEventListener().onRetry(); _exchange.reset(); _exchange.setEventListener(listener);
String reason = _endp.isOpen()?(_endp.isInputShutdown()?"half closed: ":"local close: "):"closed: "; if (exchange.setStatus(HttpExchange.STATUS_EXCEPTED)) exchange.getEventListener().onException(new EofException(reason+exch));
exchange.getEventListener().onRequestComplete(); exchange.getEventListener().onException(e);
progress=true; _requestComplete = true; exchange.getEventListener().onRequestComplete(); exchange.getEventListener().onException(e);