QueryStringDecoder { public Map<String, List<String>> parameters() { if (params == null) { if (hasPath) { int pathLength = path().length(); if (uri.length() == pathLength) { return Collections.emptyMap(); } decodeParams(uri.substring(pathLength + 1)); } else { if (uri.isEmpty()) { return Collections.emptyMap(); } decodeParams(uri); } } return params; } QueryStringDecoder(String uri);  QueryStringDecoder(String uri, boolean hasPath);  QueryStringDecoder(String uri, Charset charset);  QueryStringDecoder(String uri, Charset charset, boolean hasPath);  QueryStringDecoder(String uri, Charset charset, boolean hasPath, int maxParams);  QueryStringDecoder(URI uri);  QueryStringDecoder(URI uri, Charset charset);  QueryStringDecoder(URI uri, Charset charset, int maxParams); String uri(); String path(); Map<String, List<String>> parameters(); static String decodeComponent(final String s); static String decodeComponent(final String s, final Charset charset);  }
@Test public void testBasicUris() throws URISyntaxException { QueryStringDecoder d = new QueryStringDecoder(new URI("http: Assert.assertEquals(0, d.parameters().size()); }
@Test public void testHashDos() throws Exception { StringBuilder buf = new StringBuilder(); buf.append('?'); for (int i = 0; i < 65536; i ++) { buf.append('k'); buf.append(i); buf.append("=v"); buf.append(i); buf.append('&'); } Assert.assertEquals(1024, new QueryStringDecoder(buf.toString()).parameters().size()); }