/** * Return the protocol and version used to make this Request. */ public Protocol getProtocol() { return request.getProtocol(); }
/** * Return the protocol and version used to make this Request. */ public Protocol getProtocol() { return request.getProtocol(); }
/** * Return the protocol and version used to make this Request. */ public Protocol getProtocol() { return request.getProtocol(); }
@Override public HttpProtocol getProtocol() { if (this.protocol == null) { this.protocol = requestPacket.getProtocol() == Protocol.HTTP_1_0 ? HttpProtocol.HTTP_1_0 : HttpProtocol.HTTP_1_1; } return this.protocol; }
@Override public HttpProtocol getProtocol() { if (this.protocol == null) { this.protocol = requestPacket.getProtocol() == Protocol.HTTP_1_0 ? HttpProtocol.HTTP_1_0 : HttpProtocol.HTTP_1_1; } return this.protocol; }
/** * Return the protocol and version used to make this Request. */ public Protocol getProtocol() { return request.getProtocol(); }
/** * Return the protocol and version used to make this Request. */ public Protocol getProtocol() { return request.getProtocol(); }
/** * Return the protocol and version used to make this Request. */ public Protocol getProtocol() { return request.getProtocol(); }
/** * Return the protocol and version used to make this Request. */ public Protocol getProtocol() { return request.getProtocol(); }
/** * Return the protocol and version used to make this Request. */ public Protocol getProtocol() { return request.getProtocol(); }
/** * Return the protocol and version used to make this Request. */ public Protocol getProtocol() { return request.getProtocol(); }
/** * Return the protocol and version used to make this Request. */ public Protocol getProtocol() { return request.getProtocol(); }
/** * Return the protocol and version used to make this Request. */ public Protocol getProtocol() { return request.getProtocol(); }
private void setKeepAliveForHeader(final Header header, final HttpRequestPacket requestPacket) { final MimeHeaders headers = requestPacket.getHeaders(); // Assign Connection: ... if needed if (!headers.contains(header)) { if (requestPacket.getProcessingState().isKeepAlive()) { headers.addValue(header).setBytes(KEEP_ALIVE_VALUE.getByteArray()); } else if (Protocol.HTTP_1_1.equals(requestPacket.getProtocol())) { headers.addValue(header).setBytes(CLOSE_VALUE.getByteArray()); } // switch (requestPacket.getProtocol()) { // case HTTP_0_9: // case HTTP_1_0: // if (requestPacket.getProcessingState().isKeepAlive()) { // headers.addValue(header).setBytes(KEEP_ALIVE_VALUE.getByteArray()); // } // break; // case HTTP_1_1: // if (!requestPacket.getProcessingState().isKeepAlive()) { // headers.addValue(header).setBytes(CLOSE_VALUE.getByteArray()); // } // break; // } } }
/** * {@inheritDoc} */ @Override public String toString() { final StringBuilder sb = new StringBuilder(256); sb.append("HttpRequestPacket (\n method=").append(getMethod()) .append("\n url=").append(getRequestURI()) .append("\n query=").append(getQueryString()) .append("\n protocol=").append(getProtocol().getProtocolString()) .append("\n content-length=").append(getContentLength()) .append("\n headers=["); final MimeHeaders headersLocal = getHeaders(); for (final String name : headersLocal.names()) { for (String value : headersLocal.values(name)) { sb.append("\n ").append(name).append('=').append(value); } } sb.append("]\n)"); return sb.toString(); }
/** * {@inheritDoc} */ @Override public String toString() { final StringBuilder sb = new StringBuilder(256); sb.append("HttpRequestPacket (\n method=").append(getMethod()) .append("\n url=").append(getRequestURI()) .append("\n query=").append(getQueryString()) .append("\n protocol=").append(getProtocol().getProtocolString()) .append("\n content-length=").append(getContentLength()) .append("\n headers=["); final MimeHeaders headersLocal = getHeaders(); for (final String name : headersLocal.names()) { for (String value : headersLocal.values(name)) { sb.append("\n ").append(name).append('=').append(value); } } sb.append("]\n)"); return sb.toString(); }
@Before public void setUp() { HttpEntity entity = new ByteArrayHttpEntity(new byte[1]); responseMock = mock(HttpResponse.class); when(request.getProtocol()).thenReturn(HTTP_1_1); when(responseMock.getEntity()).thenReturn(entity); when(ctx.getConnection()).thenReturn(connection); when(connection.getMemoryManager()).thenReturn(null); when(ctx.getMemoryManager()).thenReturn(null); }
public ResponseCompletionHandler(final FilterChainContext ctx, final HttpRequestPacket httpRequestPacket, final HttpResponse httpResponse, ResponseStatusCallback responseStatusCallback) { checkArgument((!(httpResponse.getEntity().isStreaming())), "HTTP response entity cannot be stream based"); this.ctx = ctx; this.protocol = httpRequestPacket.getProtocol(); this.httpResponsePacket = buildHttpResponsePacket(httpRequestPacket, httpResponse); this.httpResponseContent = buildResponseContent(httpResponse); this.responseStatusCallback = responseStatusCallback; }
/** * Construct a DownloadCompletionHandler * * @param ctx Suspended HttpRequestPacket processing context * @param request HttpRequestPacket message header * @param file local file to be sent * @throws FileNotFoundException */ public DownloadCompletionHandler(FilterChainContext ctx, HttpRequestPacket request, File file) throws FileNotFoundException { // Open file input stream in = new FileInputStream(file); this.ctx = ctx; // Build HttpResponsePacket message header (send file using chunked HTTP messages). response = HttpResponsePacket.builder(request). protocol(request.getProtocol()).status(200). reasonPhrase("OK").chunked(true).build(); memoryManager = ctx.getMemoryManager(); }
/** * Create a 404 HttpResponsePacket packet * @param request original HttpRequestPacket * * @return 404 HttpContent */ private static HttpPacket create404(HttpRequestPacket request) throws CharConversionException { // Build 404 HttpResponsePacket message headers final HttpResponsePacket responseHeader = HttpResponsePacket.builder(request). protocol(request.getProtocol()).status(404). reasonPhrase("Not Found").build(); // Build 404 HttpContent on base of HttpResponsePacket message header return responseHeader.httpContentBuilder(). content(Buffers.wrap(null, "Can not find file, corresponding to URI: " + request.getRequestURIRef().getDecodedURI())). build(); }