@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 protected T createMessage(final CharArrayBuffer buffer) throws HttpException { final StatusLine statusLine = getLineParser().parseStatusLine(buffer); final T response = this.responseFactory.newHttpResponse(statusLine.getStatusCode(), statusLine.getReasonPhrase()); response.setVersion(statusLine.getProtocolVersion()); return response; }
buf.append("HTTP/1.1 200 OK"); StatusLine statusLine = this.parser.parseStatusLine(buf); Assert.assertEquals("HTTP/1.1 200 OK", statusLine.toString()); Assert.assertEquals(HttpVersion.HTTP_1_1, statusLine.getProtocolVersion()); Assert.assertEquals(200, statusLine.getStatusCode()); Assert.assertEquals("OK", statusLine.getReasonPhrase()); buf.append("HTTP/1.1 404 Not Found"); statusLine = this.parser.parseStatusLine(buf); Assert.assertEquals(404, statusLine.getStatusCode()); Assert.assertEquals("Not Found", statusLine.getReasonPhrase()); buf.append("HTTP/1.1 404 Non Trouve"); statusLine = this.parser.parseStatusLine(buf); Assert.assertEquals("Non Trouve", statusLine.getReasonPhrase()); buf.append("HTTP/1.1 404 Not Found\r\n"); statusLine = this.parser.parseStatusLine(buf); Assert.assertEquals("Not Found", statusLine.getReasonPhrase()); buf.append("HTTP/1.1 200 "); statusLine = this.parser.parseStatusLine(buf); Assert.assertEquals(200, statusLine.getStatusCode()); Assert.assertEquals("", statusLine.getReasonPhrase()); buf.append("HTTP/1.1 200"); statusLine = this.parser.parseStatusLine(buf); Assert.assertEquals(200, statusLine.getStatusCode()); Assert.assertEquals("", statusLine.getReasonPhrase());
@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 T createMessage(final CharArrayBuffer buffer) throws HttpException { final StatusLine statusLine = getLineParser().parseStatusLine(buffer); final T response = this.responseFactory.newHttpResponse(statusLine.getStatusCode(), statusLine.getReasonPhrase()); response.setVersion(statusLine.getProtocolVersion()); return response; }
@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 ClassicHttpResponse createMessage(final CharArrayBuffer buffer) throws IOException, HttpException { final StatusLine statusline = getLineParser().parseStatusLine(buffer); final ClassicHttpResponse response = this.responseFactory.newHttpResponse(statusline.getStatusCode(), statusline.getReasonPhrase()); response.setVersion(statusline.getProtocolVersion()); return response; }
@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 ClassicHttpResponse createMessage(final CharArrayBuffer buffer) throws IOException, HttpException { final StatusLine statusline = getLineParser().parseStatusLine(buffer); final ClassicHttpResponse response = this.responseFactory.newHttpResponse(statusline.getStatusCode(), statusline.getReasonPhrase()); response.setVersion(statusline.getProtocolVersion()); return response; }
@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 formatStatusLine(final CharArrayBuffer buffer, final StatusLine statline) { Args.notNull(buffer, "Char array buffer"); Args.notNull(statline, "Status line"); formatProtocolVersion(buffer, statline.getProtocolVersion()); buffer.append(' '); buffer.append(Integer.toString(statline.getStatusCode())); buffer.append(' '); // keep whitespace even if reason phrase is empty final String reasonPhrase = statline.getReasonPhrase(); if (reasonPhrase != null) { buffer.append(reasonPhrase); } }
@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 formatStatusLine(final CharArrayBuffer buffer, final StatusLine statline) { Args.notNull(buffer, "Char array buffer"); Args.notNull(statline, "Status line"); formatProtocolVersion(buffer, statline.getProtocolVersion()); buffer.append(' '); buffer.append(Integer.toString(statline.getStatusCode())); buffer.append(' '); // keep whitespace even if reason phrase is empty final String reasonPhrase = statline.getReasonPhrase(); if (reasonPhrase != null) { buffer.append(reasonPhrase); } }
@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 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); } }