AbstractHttpConnection disassociate() { AbstractHttpConnection result = _connection; this._connection = null; if (getStatus() == STATUS_CANCELLING) setStatus(STATUS_CANCELLED); return result; }
@Override public String toString() { String state=toState(getStatus()); long now=System.currentTimeMillis(); long forMs = now -_lastStateChange; String s= _lastState>=0 ?String.format("%s@%x=%s//%s%s#%s(%dms)->%s(%dms)",getClass().getSimpleName(),hashCode(),_method,_address,_uri,toState(_lastState),_lastStatePeriod,state,forMs) :String.format("%s@%x=%s//%s%s#%s(%dms)",getClass().getSimpleName(),hashCode(),_method,_address,_uri,state,forMs); if (getStatus()>=STATUS_SENDING_REQUEST && _sent>0) s+="sent="+(now-_sent)+"ms"; return s; }
protected void send(AbstractHttpConnection connection, HttpExchange exchange) throws IOException { synchronized (this) { // If server closes the connection, put the exchange back // to the exchange queue and recycle the connection if (!connection.send(exchange)) { if (exchange.getStatus() <= HttpExchange.STATUS_WAITING_FOR_CONNECTION) _exchanges.add(0, exchange); returnIdleConnection(connection); } } }
/** * */ private void stopServer() { HttpClient client = new HttpClient(); try { final HttpExchange exchange = new HttpExchange(); exchange.setMethod("POST"); exchange.setURL(String.format("http://127.0.0.1:%s/shutdown?secret=%s", port, secret)); client.send(exchange); log.info("LOG00010: shutdown status {}", exchange.getStatus()); } catch (IOException e) { log.error("LOG00020: Can't stop server gracefully", e); } }
protected void expire(HttpDestination destination) { AbstractHttpConnection connection = _connection; int status = getStatus(); if (status < STATUS_COMPLETED || status == STATUS_SENDING_PARSING_HEADERS || status == STATUS_SENDING_PARSING_CONTENT || status == STATUS_SENDING_COMPLETED) setStatus(STATUS_EXPIRED); destination.exchangeExpired(this); if (connection != null) connection.exchangeExpired(this); }
void associate(AbstractHttpConnection connection) { if (connection.getEndPoint().getLocalAddr() != null) _localAddress = new Address(connection.getEndPoint().getLocalAddr(),connection.getEndPoint().getLocalPort()); _connection = connection; if (getStatus() == STATUS_CANCELLING) abort(); }
if (_exchange.getStatus() != HttpExchange.STATUS_WAITING_FOR_COMMIT) throw new IllegalStateException();
if (exchange != null && !exchange.isDone()) switch (exchange.getStatus())
if (!_generator.isCommitted() && exchange!=null && exchange.getStatus() == HttpExchange.STATUS_WAITING_FOR_COMMIT) progress=true; _generator.complete(); if (exchange.getStatus() < HttpExchange.STATUS_WAITING_FOR_RESPONSE) exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE); if (exchange.getStatus() != HttpExchange.STATUS_CANCELLING && exchange.getStatus() != HttpExchange.STATUS_CANCELLED && !exchange.isDone())