@Override public void handle(final Request request, final Response response) { final ResponseWriter responseWriter = new ResponseWriter(response, scheduler); final URI baseUri = getBaseUri(request); final URI requestUri = getRequestUri(request, baseUri); try { final ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri, request.getMethod(), getSecurityContext(request), new MapPropertiesDelegate()); requestContext.setEntityStream(request.getInputStream()); for (final String headerName : request.getNames()) { requestContext.headers(headerName, request.getValue(headerName)); } requestContext.setWriter(responseWriter); requestContext.setRequestScopedInitializer(injectionManager -> { injectionManager.<Ref<Request>>getInstance(RequestTYPE).set(request); injectionManager.<Ref<Response>>getInstance(ResponseTYPE).set(response); }); appHandler.handle(requestContext); } catch (final Exception ex) { throw new RuntimeException(ex); } finally { if (!responseWriter.isSuspended()) { close(response); } } }
/** * This method is used to get a <code>List</code> of the names * for the headers. This will provide the original names for the * HTTP headers for the message. Modifications to the provided * list will not affect the header, the list is a simple copy. * * @return this returns a list of the names within the header */ public List<String> getNames() { return request.getNames(); }
/** * This method is used to get a <code>List</code> of the names * for the headers. This will provide the original names for the * HTTP headers for the message. Modifications to the provided * list will not affect the header, the list is a simple copy. * * @return this returns a list of the names within the header */ public List<String> getNames() { return request.getNames(); }
/** * This method is used to get a <code>List</code> of the names * for the headers. This will provide the original names for the * HTTP headers for the message. Modifications to the provided * list will not affect the header, the list is a simple copy. * * @return this returns a list of the names within the header */ public List<String> getNames() { return request.getNames(); }
@Override public List<String> headerNames() { return request.getNames(); }
public List<String> getHeaderNames() { return request.getNames(); }
public Map<String, String> getHeaders() { Map<String, String> headers = new HashMap<String, String>(); for (String s : baseRequest.getNames()) { String val = baseRequest.getValue(s); headers.put(s, val); } return headers; }
private InBoundHeaders getHeaders(Request request) { InBoundHeaders header = new InBoundHeaders(); List<String> names = request.getNames(); for (String name : names) { String value = request.getValue(name); header.add(name, value); } return header; }
/** * Returns the list of request headers. * * @return The list of request headers. */ @Override public Series<Parameter> getRequestHeaders() { final Series<Parameter> result = super.getRequestHeaders(); if (!this.requestHeadersAdded) { final List<String> names = this.request.getNames(); for (String name : names) { result.add(new Parameter(name, this.request.getValue(name))); } this.requestHeadersAdded = true; } return result; }
public static FullHttpRequest convert(final Request request) { byte[] data = null; try { final InputStream inputStream = request.getInputStream(); try { data = IOUtils.toByteArray(inputStream); } finally { inputStream.close(); } } catch (final IOException e) { LOGGER.error("IOException when getting request content.", e); } final FullHttpRequestImpl httpRequest = new FullHttpRequestImpl(); httpRequest.domain(request.getAddress().getDomain()); httpRequest.port(request.getAddress().getPort()); httpRequest.method(Method.valueOf(request.getMethod())); httpRequest.path(request.getPath().getPath()); if (data.length > 0) { httpRequest.content(data); } for (final String headerField : request.getNames()) { for (final String headerFieldValue : request.getValues(headerField)) { httpRequest.httpMessageHeader(headerField, headerFieldValue); } } for (final Entry<String, String> entry : request.getQuery().entrySet()) { httpRequest.queryParameter(entry.getKey(), entry.getValue()); } return httpRequest; }
@Override public void handle(final Request request, final Response response) { final ResponseWriter responseWriter = new ResponseWriter(response, scheduler); final URI baseUri = getBaseUri(request); final URI requestUri = getRequestUri(request, baseUri); try { final ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri, request.getMethod(), getSecurityContext(request), new MapPropertiesDelegate()); requestContext.setEntityStream(request.getInputStream()); for (final String headerName : request.getNames()) { requestContext.headers(headerName, request.getValue(headerName)); } requestContext.setWriter(responseWriter); requestContext.setRequestScopedInitializer(injectionManager -> { injectionManager.<Ref<Request>>getInstance(RequestTYPE).set(request); injectionManager.<Ref<Response>>getInstance(ResponseTYPE).set(response); }); appHandler.handle(requestContext); } catch (final Exception ex) { throw new RuntimeException(ex); } finally { if (!responseWriter.isSuspended()) { close(response); } } }