/** * Adds a listener that will be invoked on response commit * * @param listener The response listener */ public void addResponseCommitListener(final ResponseCommitListener listener) { //technically it is possible to modify the exchange after the response conduit has been created //as the response channel should not be retrieved until it is about to be written to //if we get complaints about this we can add support for it, however it makes the exchange bigger and the connectors more complex addResponseWrapper(new ConduitWrapper<StreamSinkConduit>() { @Override public StreamSinkConduit wrap(ConduitFactory<StreamSinkConduit> factory, HttpServerExchange exchange) { listener.beforeCommit(exchange); return factory.create(); } }); }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { exchange.addResponseWrapper(new ConduitWrapper<StreamSinkConduit>() { @Override public StreamSinkConduit wrap(ConduitFactory<StreamSinkConduit> factory, HttpServerExchange exchange) { return new StoredResponseStreamSinkConduit(factory.create(), exchange); } }); next.handleRequest(exchange); }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { exchange.addResponseWrapper(WRAPPER); next.handleRequest(exchange); }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { Cookie sessionId = exchange.getRequestCookies().get(sessionCookieName); if (sessionId != null) { int part = sessionId.getValue().indexOf('.'); if (part != -1) { sessionId.setValue(sessionId.getValue().substring(0, part)); } } exchange.addResponseWrapper(wrapper); next.handleRequest(exchange); }
final ResponseCache responseCache = new ResponseCache(cache, exchange); exchange.putAttachment(ResponseCache.ATTACHMENT_KEY, responseCache); exchange.addResponseWrapper(new ConduitWrapper<StreamSinkConduit>() { @Override public StreamSinkConduit wrap(final ConduitFactory<StreamSinkConduit> factory, final HttpServerExchange exchange) {
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { AllowedContentEncodings encodings = contentEncodingRepository.getContentEncodings(exchange); if (encodings == null || !exchange.isResponseChannelAvailable()) { next.handleRequest(exchange); } else if (encodings.isNoEncodingsAllowed()) { noEncodingHandler.handleRequest(exchange); } else { exchange.addResponseWrapper(encodings); exchange.putAttachment(AllowedContentEncodings.ATTACHMENT_KEY, encodings); next.handleRequest(exchange); } }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { AllowedContentEncodings encodings = contentEncodingRepository.getContentEncodings(exchange); if (encodings == null || !exchange.isResponseChannelAvailable()) { Handler.next(exchange, next); } else if (encodings.isNoEncodingsAllowed()) { setExchangeStatus(exchange, NO_ENCODING_HANDLER); return; } else { exchange.addResponseWrapper(encodings); exchange.putAttachment(AllowedContentEncodings.ATTACHMENT_KEY, encodings); Handler.next(exchange, next); } } }
exchange.addResponseWrapper(responseListener); return AuthenticationMechanismOutcome.NOT_ATTEMPTED;
exchange.setProtocol(Protocols.HTTP_2_0); if(exchange.getRequestMethod().equals(Methods.HEAD)) { exchange.addResponseWrapper(new ConduitWrapper<StreamSinkConduit>() { @Override public StreamSinkConduit wrap(ConduitFactory<StreamSinkConduit> factory, HttpServerExchange exchange) {
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { if (exchange.isInIoThread()) { exchange.dispatch(this); return; } if(isEnabled()) { Map<String, Object> result = new LinkedHashMap<>(); //create rootDumper which will do dumping. RootDumper rootDumper = new RootDumper(config, exchange); //dump request info into result right away rootDumper.dumpRequest(result); //only add response wrapper when response config is not set to "false" if(config.isResponseEnabled()) { //set Conduit to the conduit chain to store response body exchange.addResponseWrapper((factory, exchange12) -> new StoreResponseStreamSinkConduit(factory.create(), exchange12)); } //when complete exchange, dump response info to result, and log the result. exchange.addExchangeCompleteListener((exchange1, nextListener) ->{ rootDumper.dumpResponse(result); //log the result DumpHelper.logResult(result, config); nextListener.proceed(); }); } Handler.next(exchange, next); } }
exchange.addResponseWrapper(new ConduitWrapper<StreamSinkConduit>() { @Override public StreamSinkConduit wrap(ConduitFactory<StreamSinkConduit> factory, HttpServerExchange exchange) {
newExchange.addResponseWrapper(new ConduitWrapper<StreamSinkConduit>() { @Override public StreamSinkConduit wrap(ConduitFactory<StreamSinkConduit> factory, HttpServerExchange exchange) {
newExchange.addResponseWrapper(new ConduitWrapper<StreamSinkConduit>() { @Override public StreamSinkConduit wrap(ConduitFactory<StreamSinkConduit> factory, HttpServerExchange exchange) {
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { exchange.addResponseWrapper(WRAPPER); next.handleRequest(exchange); }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { exchange.addResponseWrapper(new ConduitWrapper<StreamSinkConduit>() { @Override public StreamSinkConduit wrap(ConduitFactory<StreamSinkConduit> factory, HttpServerExchange exchange) { return new StoredResponseStreamSinkConduit(factory.create(), exchange); } }); next.handleRequest(exchange); }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { exchange.addResponseWrapper(WRAPPER); next.handleRequest(exchange); }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { exchange.addResponseWrapper(new ConduitWrapper<StreamSinkConduit>() { @Override public StreamSinkConduit wrap(ConduitFactory<StreamSinkConduit> factory, HttpServerExchange exchange) { return new StoredResponseStreamSinkConduit(factory.create(), exchange); } }); next.handleRequest(exchange); }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { if (exchange == null) return; exchange.addResponseWrapper(new ConduitWrapper<StreamSinkConduit>() { @Override public StreamSinkConduit wrap(ConduitFactory<StreamSinkConduit> factory, HttpServerExchange exchange) { return new BytesSentStreamSinkConduit(factory.create()); } }); wrappedHandler.handleRequest(exchange); } }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { Cookie sessionId = exchange.getRequestCookies().get(sessionCookieName); if (sessionId != null) { int part = sessionId.getValue().indexOf('.'); if (part != -1) { sessionId.setValue(sessionId.getValue().substring(0, part)); } } exchange.addResponseWrapper(wrapper); next.handleRequest(exchange); }
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { AllowedContentEncodings encodings = contentEncodingRepository.getContentEncodings(exchange); if (encodings == null || !exchange.isResponseChannelAvailable()) { next.handleRequest(exchange); } else if (encodings.isNoEncodingsAllowed()) { noEncodingHandler.handleRequest(exchange); } else { exchange.addResponseWrapper(encodings); exchange.putAttachment(AllowedContentEncodings.ATTACHMENT_KEY, encodings); next.handleRequest(exchange); } }