private URI getRequestUri(final Request request, final URI baseUri) { try { final String serverAddress = getServerAddress(baseUri); String uri = ContainerUtils.getHandlerPath(request.getTarget()); final String queryString = request.getQuery().toString(); if (queryString != null) { uri = uri + "?" + ContainerUtils.encodeUnsafeCharacters(queryString); } return new URI(serverAddress + uri); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex); } }
/** * This method is used to insert a collection of tokens into * the parsers map. This is used when another source of tokens * is required to populate the connection currently maintained * within this parsers internal map. Any tokens that currently * exist with similar names will be overwritten by this. * * @param query this is the collection of tokens to be added */ private void add(Query query) { Set<String> keySet = query.keySet(); for(String key : keySet) { List<String> list = query.getAll(key); String first = query.get(key); if(first != null) { all.put(key, list); map.put(key, first); } } } }
@Override public String get(String name) { return query.get(name); }
@Override public ImmutableMap<String, ImmutableList<String>> getQueryParams() { if (queryParams == null) { ImmutableMap.Builder<String, ImmutableList<String>> paramsBuilder = ImmutableMap.builder(); Query query = request.getQuery(); for (String param : query.keySet()) { paramsBuilder.put(param, ImmutableList.copyOf(query.getAll(param))); } queryParams = paramsBuilder.build(); } return queryParams; }
@Override public Collection<String> keys() { return query.keySet(); }
@Override public Iterable<String> all(String name) { return query.getAll(name); }
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; }
/** * This method is used to insert a collection of tokens into * the parsers map. This is used when another source of tokens * is required to populate the connection currently maintained * within this parsers internal map. Any tokens that currently * exist with similar names will be overwritten by this. * * @param query this is the collection of tokens to be added */ private void add(Query query) { Set<String> keySet = query.keySet(); for(String key : keySet) { List<String> list = query.getAll(key); String first = query.get(key); if(first != null) { all.put(key, list); map.put(key, first); } } } }
@Override public Optional<String> getQueryParam(String param) { return Optional.fromNullable(request.getQuery().get(param)); }
@Override public ImmutableMap<String, ImmutableList<String>> getQueryParams() { if (queryParams == null) { ImmutableMap.Builder<String, ImmutableList<String>> paramsBuilder = ImmutableMap.builder(); Query query = request.getQuery(); for (String param : query.keySet()) { paramsBuilder.put(param, ImmutableList.copyOf(query.getAll(param))); } queryParams = paramsBuilder.build(); } return queryParams; }
public Set<String> getRequestParameterNames() { return request.getQuery().keySet(); }
@Override public List<String> getQueryParams(String param) { List<String> queryParams = request.getQuery().getAll(param); return queryParams==null?null:Lists.newArrayList(queryParams); }
/** * This method is used to insert a collection of tokens into * the parsers map. This is used when another source of tokens * is required to populate the connection currently maintained * within this parsers internal map. Any tokens that currently * exist with similar names will be overwritten by this. * * @param query this is the collection of tokens to be added */ private void add(Query query) { Set<String> keySet = query.keySet(); for(String key : keySet) { List<String> list = query.getAll(key); String first = query.get(key); if(first != null) { all.put(key, list); map.put(key, first); } } } }
/** * This is used to provide quick access to the parameters. This * avoids having to acquire the request <code>Form</code> object. * This basically acquires the parameters object and invokes * the <code>getParameters</code> method with the given name. * * @param name this is the name of the parameter value */ public String getParameter(String name) { return getQuery().get(name); }
@Override public List<String> getQueryParams(String param) { List<String> queryParams = request.getQuery().getAll(param); return queryParams==null?null:Lists.newArrayList(queryParams); }
public String getQuery() { return request.getQuery().toString(); }
/** * This is used to provide quick access to the parameters. This * avoids having to acquire the request <code>Form</code> object. * This basically acquires the parameters object and invokes * the <code>getParameters</code> method with the given name. * * @param name this is the name of the parameter value */ public String getParameter(String name) { return getQuery().get(name); }
private URI getRequestUri(final Request request, final URI baseUri) { try { final String serverAddress = getServerAddress(baseUri); String uri = ContainerUtils.getHandlerPath(request.getTarget()); final String queryString = request.getQuery().toString(); if (queryString != null) { uri = uri + "?" + ContainerUtils.encodeUnsafeCharacters(queryString); } return new URI(serverAddress + uri); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex); } }