Tabnine Logo
QueryStringDecoder
Code IndexAdd Tabnine to your IDE (free)

How to use
QueryStringDecoder
in
org.jboss.netty.handler.codec.http

Best Java code snippets using org.jboss.netty.handler.codec.http.QueryStringDecoder (Showing top 20 results out of 315)

origin: apache/hive

 new QueryStringDecoder(request.getUri()).getParameters();
final List<String> keepAliveList = q.get("keepAlive");
boolean keepAliveParam = false;
origin: io.netty/netty

/**
 * Returns the decoded key-value parameter pairs of the URI.
 */
public Map<String, List<String>> getParameters() {
  if (params == null) {
    if (hasPath) {
      int pathLength = getPath().length();
      if (uri.length() == pathLength) {
        return Collections.emptyMap();
      }
      decodeParams(uri.substring(pathLength + 1));
    } else {
      if (uri.length() == 0) {
        return Collections.emptyMap();
      }
      decodeParams(uri);
    }
  }
  return params;
}
origin: io.netty/netty

if (c == '=' && name == null) {
  if (pos != i) {
    name = decodeComponent(s.substring(pos, i), charset);
    if (!addParam(params, decodeComponent(s.substring(pos, i), charset), "")) {
      return;
    if (!addParam(params, name, decodeComponent(s.substring(pos, i), charset))) {
      return;
  addParam(params, decodeComponent(s.substring(pos, i), charset), "");
} else {                // Yes and this must be the last value.
  addParam(params, name, decodeComponent(s.substring(pos, i), charset));
addParam(params, name, "");
origin: cgbystrom/netty-tools

protected String sanitizeUri(String uri) throws URISyntaxException {
  // Decode the path.
  try {
    uri = URLDecoder.decode(uri, "UTF-8");
  } catch (UnsupportedEncodingException e) {
    try {
      uri = URLDecoder.decode(uri, "ISO-8859-1");
    } catch (UnsupportedEncodingException e1) {
      throw new Error();
    }
  }
  // Convert file separators.
  uri = uri.replace(File.separatorChar, '/');
  // Simplistic dumb security check.
  // You will have to do something serious in the production environment.
  if (uri.contains(File.separator + ".") ||
    uri.contains("." + File.separator) ||
    uri.startsWith(".") || uri.endsWith(".")) {
    return null;
  }
  QueryStringDecoder decoder = new QueryStringDecoder(uri);
  uri = decoder.getPath();
  if (uri.endsWith("/")) {
    uri += "index.html";
  }
  return uri;
}
origin: k3po/k3po

httpChildConfig.setVersion(version);
httpChildConfig.getReadHeaders().set(httpRequest.headers());
httpChildConfig.setReadQuery(new QueryStringDecoder(httpRequest.getUri()));
httpChildConfig.setWriteQuery(new QueryStringEncoder(httpRequest.getUri()));
httpChildConfig.setStatus(HttpResponseStatus.OK);
origin: k3po/k3po

@Override
public boolean decode(Channel channel) throws Exception {
  HttpChannelConfig httpConfig = (HttpChannelConfig) channel.getConfig();
  QueryStringDecoder query = httpConfig.getReadQuery();
  Map<String, List<String>> parameters = query.getParameters();
  List<String> parameterValues = parameters.get(name);
  if (valueDecoders.size() == 1) {
    MessageDecoder valueDecoder = valueDecoders.get(0);
    decodeParameterValue(parameters, parameterValues, valueDecoder);
  }
  else {
    for (MessageDecoder valueDecoder : valueDecoders) {
      decodeParameterValue(parameters, parameterValues, valueDecoder);
    }
  }
  return true;
}
origin: cgbystrom/sockjs-netty

public void handle(HttpRequest request, HttpResponse response) {
  QueryStringDecoder qsd = new QueryStringDecoder(request.getUri());
  String path = qsd.getPath();
  if (!path.matches(".*/iframe[0-9-.a-z_]*.html")) {
    response.setStatus(HttpResponseStatus.NOT_FOUND);
    response.setContent(ChannelBuffers.copiedBuffer("Not found", CharsetUtil.UTF_8));
    return;
  }
  response.setHeader(HttpHeaders.Names.SET_COOKIE, "JSESSIONID=dummy; path=/");
  if (request.containsHeader(HttpHeaders.Names.IF_NONE_MATCH)) {
    response.setStatus(HttpResponseStatus.NOT_MODIFIED);
    response.removeHeader(HttpHeaders.Names.CONTENT_TYPE);
  } else {
    response.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/html; charset=UTF-8");
    response.setHeader(HttpHeaders.Names.CACHE_CONTROL, "max-age=31536000, public");
    response.setHeader(HttpHeaders.Names.EXPIRES, "FIXME"); // FIXME: Fix this
    response.removeHeader(HttpHeaders.Names.SET_COOKIE);
    response.setContent(content);
  }
  response.setHeader(HttpHeaders.Names.ETAG, etag);
}
 
origin: org.vert-x/vertx-core

public Map<String, String> params() {
 if (params == null) {
  QueryStringDecoder queryStringDecoder = new QueryStringDecoder(uri);
  Map<String, List<String>> prms = queryStringDecoder.getParameters();
  if (prms.isEmpty()) {
   params = new HashMap<>();
  } else {
   params = new HashMap<>(prms.size());
   for (Map.Entry<String, List<String>> entry: prms.entrySet()) {
    params.put(entry.getKey(), entry.getValue().get(0));
   }
  }
 }
 return params;
}
origin: cgbystrom/sockjs-netty

private void handleService(ChannelHandlerContext ctx, MessageEvent e, Service service) throws Exception {
  HttpRequest request = (HttpRequest)e.getMessage();
  request.setUri(request.getUri().replaceFirst(service.getUrl(), ""));
  QueryStringDecoder qsd = new QueryStringDecoder(request.getUri());
  String path = qsd.getPath();
origin: caskdata/coopr

 private ResourceStatus getStatusParam(HttpRequest request) throws IllegalArgumentException {
  Map<String, List<String>> queryParams = new QueryStringDecoder(request.getUri()).getParameters();
  return queryParams.containsKey("status") ?
   ResourceStatus.valueOf(queryParams.get("status").get(0).toUpperCase()) : null;
 }
}
origin: fjfd/microscope

/**
 * Returns the query string parameters passed in the URI.
 */
public Map<String, List<String>> getQueryString() {
  if (querystring == null) {
    try {
      querystring = new QueryStringDecoder(request.getUri()).getParameters();
    } catch (IllegalArgumentException e) {
      throw new BadRequestException("Bad query string: " + e.getMessage());
    }
  }
  return querystring;
}
origin: caskdata/coopr

 /**
  * Retrieves query parameters from {@code request}.
  *
  * @param request the request
  * @param names list of query parameters names
  * @return {@link Map} of query parameters
  */
 private Map<String, String> getFilters(HttpRequest request, List<String> names) {
  Map<String, List<String>> queryParams = new QueryStringDecoder(request.getUri()).getParameters();
  Map<String, String> filters = Maps.newHashMap();
  for (String name : names) {
   List<String> values = queryParams.get(name);
   if (values != null && !values.isEmpty()) {
    filters.put(name, values.get(0));
   }
  }

  return filters;
 }
}
origin: caskdata/coopr

 private Set<Cluster.Status> getStatusFilter(HttpRequest request) {
  Set<Cluster.Status> filter = Sets.newHashSet();
  Map<String, List<String>> queryParams = new QueryStringDecoder(request.getUri()).getParameters();
  List<String> statusParams = queryParams.get("status");
  if (statusParams != null && !statusParams.isEmpty()) {
   String statusStr = queryParams.get("status").get(0);
   String[] statuses = statusStr.split(",");
   for (String status: statuses) {
    try {
     filter.add(Cluster.Status.valueOf(status.toUpperCase()));
    } catch (IllegalArgumentException e) {
     LOG.info("Unknown cluster status {} requested.", status);
    }
   }
  }
  return filter;
 }
}
origin: cgbystrom/sockjs-netty

@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
  HttpRequest request = (HttpRequest) e.getMessage();
  QueryStringDecoder qsd = new QueryStringDecoder(request.getUri());
  final List<String> c = qsd.getParameters().get("c");
  if (c == null) {
    respond(e.getChannel(), HttpResponseStatus.INTERNAL_SERVER_ERROR, "\"callback\" parameter required.");
    return;
  }
  jsonpCallback = c.get(0);
  super.messageReceived(ctx, e);
}
origin: apifest/apifest-oauth20

protected List<ApplicationInfo> filterClientApps(HttpRequest req, List<ApplicationInfo> apps) {
  List<ApplicationInfo> filteredApps = new ArrayList<ApplicationInfo>();
  QueryStringDecoder dec = new QueryStringDecoder(req.getUri());
  Map<String, List<String>> params = dec.getParameters();
  if (params != null) {
    String status = QueryParameter.getFirstElement(params, "status");
    Integer statusInt = null;
    if (status != null && !status.isEmpty()) {
      try {
        statusInt = Integer.valueOf(status);
        for (ApplicationInfo app : apps) {
          if (app.getStatus() == statusInt) {
            filteredApps.add(app);
          }
        }
      } catch (NumberFormatException e) {
        // status is invalid, ignore it
        filteredApps = Collections.unmodifiableList(apps);
      }
    } else {
      filteredApps = Collections.unmodifiableList(apps);
    }
  }
  return filteredApps;
}
origin: cgbystrom/sockjs-netty

public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
  HttpRequest request = (HttpRequest) e.getMessage();
  QueryStringDecoder qsd = new QueryStringDecoder(request.getUri());
  final List<String> c = qsd.getParameters().get("c");
  if (c == null) {
    respond(e.getChannel(), HttpResponseStatus.INTERNAL_SERVER_ERROR, "\"callback\" parameter required.");
    return;
  }
  final String callback = c.get(0);
  header = ChannelBuffers.wrappedBuffer(HEADER_PART1, ChannelBuffers.copiedBuffer(callback, CharsetUtil.UTF_8), HEADER_PART2);
  super.messageReceived(ctx, e);
}
origin: apifest/apifest-oauth20

protected HttpResponse handleTokenValidate(HttpRequest req) {
  HttpResponse response = null;
  QueryStringDecoder dec = new QueryStringDecoder(req.getUri());
  Map<String, List<String>> params = dec.getParameters();
  String tokenParam = QueryParameter.getFirstElement(params, QueryParameter.TOKEN);
  if (tokenParam == null || tokenParam.isEmpty()) {
    response = Response.createBadRequestResponse();
  } else {
    AccessToken token = auth.isValidToken(tokenParam);
    if (token != null) {
      Gson gson = new Gson();
      String json = gson.toJson(token);
      log.debug(json);
      response = Response.createOkResponse(json);
    } else {
      response = Response.createUnauthorizedResponse();
    }
  }
  return response;
}
origin: org.apache.tajo/tajo-yarn-pullserver

new QueryStringDecoder(request.getUri()).getParameters();
origin: apifest/apifest-oauth20

/**
 * Returns either all scopes or scopes for a specific client_id passed as query parameter.
 *
 * @param req request
 * @return string If query param client_id is passed, then the scopes for that client_id will be returned.
 * Otherwise, all available scopes will be returned in JSON format.
 */
public String getScopes(HttpRequest req) throws OAuthException {
  QueryStringDecoder dec = new QueryStringDecoder(req.getUri());
  Map<String, List<String>> queryParams = dec.getParameters();
  if(queryParams.containsKey("client_id")) {
    return getScopes(queryParams.get("client_id").get(0));
  }
  List<Scope> scopes = DBManagerFactory.getInstance().getAllScopes();
  ObjectMapper mapper = new ObjectMapper();
  String jsonString;
  try {
    jsonString = mapper.writeValueAsString(scopes);
  } catch (JsonGenerationException e) {
    log.error("cannot load scopes", e);
    throw new OAuthException(e, null, HttpResponseStatus.BAD_REQUEST);
  } catch (JsonMappingException e) {
    log.error("cannot load scopes", e);
    throw new OAuthException(e, null, HttpResponseStatus.BAD_REQUEST);
  } catch (IOException e) {
    log.error("cannot load scopes", e);
    throw new OAuthException(e, null, HttpResponseStatus.BAD_REQUEST);
  }
  return jsonString;
}
origin: org.openmobster.core/dataService

QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri());
Map<String, List<String>> params = queryStringDecoder.getParameters();
if (!params.isEmpty()) {
  for (Entry<String, List<String>> p: params.entrySet()) {
    QueryStringDecoder postDecoder = new QueryStringDecoder(contentStr, false);
    Map<String, List<String>> postParams = postDecoder.getParameters();
    if (!postParams.isEmpty()) {
      for (Entry<String, List<String>> p: postParams.entrySet()) {
  QueryStringDecoder postDecoder = new QueryStringDecoder(contentStr, false);
  Map<String, List<String>> postParams = postDecoder.getParameters();
  if (!postParams.isEmpty()) {
    for (Entry<String, List<String>> p: postParams.entrySet()) {
org.jboss.netty.handler.codec.httpQueryStringDecoder

Javadoc

Splits an HTTP query string into a path string and key-value parameter pairs. This decoder is for one time use only. Create a new instance for each URI:
 
QueryStringDecoder decoder = new  
QueryStringDecoder("/hello?recipient=world&x=1;y=2"); 
assert decoder.getPath().equals("/hello"); 
assert decoder.getParameters().get("recipient").get(0).equals("world"); 
assert decoder.getParameters().get("x").get(0).equals("1"); 
assert decoder.getParameters().get("y").get(0).equals("2"); 
This decoder can also decode the content of an HTTP POST request whose content type is application/x-www-form-urlencoded:
 
QueryStringDecoder decoder = new  
QueryStringDecoder("recipient=world&x=1;y=2", false); 
... 

HashDOS vulnerability fix

As a workaround to the HashDOS vulnerability, the decoder limits the maximum number of decoded key-value parameter pairs, up to 1024 by default, and you can configure it when you construct the decoder by passing an additional integer parameter.

Most used methods

  • <init>
    Creates a new decoder that decodes the specified URI encoded in the specified charset.
  • getParameters
    Returns the decoded key-value parameter pairs of the URI.
  • getPath
    Returns the decoded path string of the URI.
  • addParam
  • decodeComponent
    Decodes a bit of an URL encoded by a browser. The string is expected to be encoded as per RFC 3986,
  • decodeHexNibble
    Helper to decode half of a hexadecimal number from a string.
  • decodeParams

Popular in Java

  • Finding current android device location
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getSystemService (Context)
  • requestLocationUpdates (LocationManager)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now