@Override public void flushCacheEntriesInvalidatedByExchange(final HttpHost host, final HttpRequest request, final HttpResponse response) { if (log.isDebugEnabled()) { log.debug("Flush cache entries invalidated by exchange: " + host + "; " + new RequestLine(request) + " -> " + new StatusLine(response)); } if (!StandardMethods.isSafe(request.getMethod())) { cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage); } }
@Override public Cancellable flushCacheEntriesInvalidatedByExchange( final HttpHost host, final HttpRequest request, final HttpResponse response, final FutureCallback<Boolean> callback) { if (log.isDebugEnabled()) { log.debug("Flush cache entries invalidated by exchange: " + host + "; " + new RequestLine(request) + " -> " + new StatusLine(response)); } if (!StandardMethods.isSafe(request.getMethod())) { return cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage, callback); } callback.completed(Boolean.TRUE); return Operations.nonCancellable(); }
@Override protected void onResponseReceived(final ClassicHttpResponse response) { if (response != null && this.headerLog.isDebugEnabled()) { this.headerLog.debug(this.id + " << " + new StatusLine(response)); final Header[] headers = response.getHeaders(); for (final Header header : headers) { this.headerLog.debug(this.id + " << " + header.toString()); } } }
@Override protected void onResponseSubmitted(final ClassicHttpResponse response) { if (response != null && this.headerLog.isDebugEnabled()) { this.headerLog.debug(this.id + " << " + new StatusLine(response)); final Header[] headers = response.getHeaders(); for (final Header header : headers) { this.headerLog.debug(this.id + " << " + header.toString()); } } }
@Override protected void onResponseSubmitted(final ClassicHttpResponse response) { if (response != null && this.headerLog.isDebugEnabled()) { this.headerLog.debug(this.id + " << " + new StatusLine(response)); final Header[] headers = response.getHeaders(); for (final Header header : headers) { this.headerLog.debug(this.id + " << " + header.toString()); } } }
@Override public void onResponseHead(final HttpConnection connection, final HttpResponse response) { if (headerLog.isDebugEnabled()) { headerLog.debug(id + " << " + new StatusLine(response)); for (final Iterator<Header> it = response.headerIterator(); it.hasNext(); ) { headerLog.debug(id + " << " + it.next()); } } }
@Override protected void onResponseReceived(final ClassicHttpResponse response) { if (response != null && this.headerLog.isDebugEnabled()) { this.headerLog.debug(this.id + " << " + new StatusLine(response)); final Header[] headers = response.getHeaders(); for (final Header header : headers) { this.headerLog.debug(this.id + " << " + header.toString()); } } }
@Override public void consumeInformation( final HttpResponse response, final HttpContext context) throws HttpException, IOException { if (log.isDebugEnabled()) { log.debug(exchangeId + ": information response " + new StatusLine(response)); } handler.consumeInformation(response, context); }
@Override protected void onResponseReceived(final ClassicHttpResponse response) { if (response != null && this.headerLog.isDebugEnabled()) { this.headerLog.debug(this.id + " << " + new StatusLine(response)); final Header[] headers = response.getHeaders(); for (final Header header : headers) { this.headerLog.debug(this.id + " << " + header.toString()); } } }
@Override public void onResponseHead(final HttpConnection connection, final HttpResponse response) { if (headerLog.isDebugEnabled()) { final String idResponseDirection = LoggingSupport.getId(connection) + responseDirection; headerLog.debug(idResponseDirection + new StatusLine(response)); for (final Iterator<Header> it = response.headerIterator(); it.hasNext(); ) { headerLog.debug(idResponseDirection + it.next()); } } }
@Override public void onResponseHead(final HttpConnection connection, final HttpResponse response) { if (headerLog.isDebugEnabled()) { final String idResponseDirection = LoggingSupport.getId(connection) + responseDirection; headerLog.debug(idResponseDirection + new StatusLine(response)); for (final Iterator<Header> it = response.headerIterator(); it.hasNext(); ) { headerLog.debug(idResponseDirection + it.next()); } } }
@Override public void consumeResponse( final HttpResponse response, final EntityDetails entityDetails, final HttpContext context) throws HttpException, IOException { if (log.isDebugEnabled()) { log.debug(exchangeId + ": consume response " + new StatusLine(response) + ", " + (entityDetails != null ? "entity len " + entityDetails.getContentLength() : " null entity")); } handler.consumeResponse(response, entityDetails, context); }
@Override public void flushCacheEntriesInvalidatedByExchange(final HttpHost host, final HttpRequest request, final HttpResponse response) { if (log.isDebugEnabled()) { log.debug("Flush cache entries invalidated by exchange: " + host + "; " + new RequestLine(request) + " -> " + new StatusLine(response)); } if (!StandardMethods.isSafe(request.getMethod())) { cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage); } }
@Override public Cancellable flushCacheEntriesInvalidatedByExchange( final HttpHost host, final HttpRequest request, final HttpResponse response, final FutureCallback<Boolean> callback) { if (log.isDebugEnabled()) { log.debug("Flush cache entries invalidated by exchange: " + host + "; " + new RequestLine(request) + " -> " + new StatusLine(response)); } if (!StandardMethods.isSafe(request.getMethod())) { return cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage, callback); } callback.completed(Boolean.TRUE); return Operations.nonCancellable(); }
@Override protected void writeHeadLine( final ClassicHttpResponse message, final CharArrayBuffer lineBuf) throws IOException { final ProtocolVersion transportVersion = message.getVersion(); getLineFormatter().formatStatusLine(lineBuf, new StatusLine( transportVersion != null ? transportVersion : HttpVersion.HTTP_1_1, message.getCode(), message.getReasonPhrase())); }
@Override protected void writeHeadLine( final ClassicHttpResponse message, final CharArrayBuffer lineBuf) throws IOException { final ProtocolVersion transportVersion = message.getVersion(); getLineFormatter().formatStatusLine(lineBuf, new StatusLine( transportVersion != null ? transportVersion : HttpVersion.HTTP_1_1, message.getCode(), message.getReasonPhrase())); }
@Override protected void writeHeadLine(final T message, final CharArrayBuffer lineBuf) throws IOException { lineBuf.clear(); final ProtocolVersion transportVersion = message.getVersion(); getLineFormatter().formatStatusLine(lineBuf, new StatusLine( transportVersion != null ? transportVersion : HttpVersion.HTTP_1_1, message.getCode(), message.getReasonPhrase())); }
@Override protected void writeHeadLine(final T message, final CharArrayBuffer lineBuf) throws IOException { lineBuf.clear(); final ProtocolVersion transportVersion = message.getVersion(); getLineFormatter().formatStatusLine(lineBuf, new StatusLine( transportVersion != null ? transportVersion : HttpVersion.HTTP_1_1, message.getCode(), message.getReasonPhrase())); }
@Test public void testSLFormatting() throws Exception { final CharArrayBuffer buf = new CharArrayBuffer(64); final StatusLine statusline1 = new StatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"); this.formatter.formatStatusLine(buf, statusline1); Assert.assertEquals("HTTP/1.1 200 OK", buf.toString()); buf.clear(); final StatusLine statusline2 = new StatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, null); this.formatter.formatStatusLine(buf, statusline2); Assert.assertEquals("HTTP/1.1 200 ", buf.toString()); // see "testSLParseSuccess" in TestBasicLineParser: // trailing space is correct }
@Test public void testSLFormattingInvalidInput() throws Exception { final CharArrayBuffer buf = new CharArrayBuffer(64); final StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"); try { this.formatter.formatStatusLine(null, statusline); Assert.fail("IllegalArgumentException should habe been thrown"); } catch (final IllegalArgumentException ex) { // expected } try { this.formatter.formatStatusLine(buf, null); Assert.fail("IllegalArgumentException should habe been thrown"); } catch (final IllegalArgumentException ex) { // expected } }