private URI getBaseUri(final Request request) { try { final String hostHeader = request.getValue("Host"); if (hostHeader != null) { final String scheme = request.isSecure() ? "https" : "http"; return new URI(scheme + "://" + hostHeader + "/"); } else { final Address address = request.getAddress(); return new URI(address.getScheme(), null, address.getDomain(), address.getPort(), "/", null, null); } } catch (final URISyntaxException ex) { throw new IllegalArgumentException(ex); } }
private URI getBaseUri(Request request) { try { final Address address = request.getAddress(); return new URI( address.getScheme(), null, address.getDomain(), address.getPort(), "/", null, null); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex); } }
private URI getBaseUri(final Request request) { try { final String hostHeader = request.getValue("Host"); if (hostHeader != null) { final String scheme = request.isSecure() ? "https" : "http"; return new URI(scheme + "://" + hostHeader + "/"); } else { final Address address = request.getAddress(); return new URI(address.getScheme(), null, address.getDomain(), address.getPort(), "/", null, null); } } catch (final URISyntaxException ex) { throw new IllegalArgumentException(ex); } }
Address a = baseRequest.getAddress(); if (host == null) { host = a.getDomain();
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; }