X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=lib%2Fjetty%2Forg%2Feclipse%2Fjetty%2Futil%2FURIUtil.java;h=193a118081c8f0d001463cc348580f683efb4156;hp=f333fc3b5f2f2106877540ac25f330907d069763;hb=ba4f228fa9f72d50991a2218cfd83987ef5d385e;hpb=875b5e9651498a0cd8e0001c0742ba843e47cad0 diff --git a/lib/jetty/org/eclipse/jetty/util/URIUtil.java b/lib/jetty/org/eclipse/jetty/util/URIUtil.java index f333fc3b..193a1180 100644 --- a/lib/jetty/org/eclipse/jetty/util/URIUtil.java +++ b/lib/jetty/org/eclipse/jetty/util/URIUtil.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. +// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ // All rights reserved. This program and the accompanying materials // are made available under the terms of the Eclipse Public License v1.0 @@ -663,7 +663,49 @@ public class URIUtil } return false; } + + /* ------------------------------------------------------------ */ + /** + * Create a new URI from the arguments, handling IPv6 host encoding and default ports + * @param scheme + * @param server + * @param port + * @param path + * @param query + * @return A String URI + */ + public static String newURI(String scheme,String server, int port,String path,String query) + { + StringBuilder builder = newURIBuilder(scheme, server, port); + builder.append(path); + if (query!=null && query.length()>0) + builder.append('?').append(query); + return builder.toString(); + } + /* ------------------------------------------------------------ */ + /** + * Create a new URI StringBuilder from the arguments, handling IPv6 host encoding and default ports + * @param scheme + * @param server + * @param port + * @return a StringBuilder containing URI prefix + */ + public static StringBuilder newURIBuilder(String scheme,String server, int port) + { + StringBuilder builder = new StringBuilder(); + appendSchemeHostPort(builder, scheme, server, port); + return builder; + } + + /* ------------------------------------------------------------ */ + /** + * Append scheme, host and port URI prefix, handling IPv6 address encoding and default ports

+ * @param url StringBuilder to append to + * @param scheme + * @param server + * @param port + */ public static void appendSchemeHostPort(StringBuilder url,String scheme,String server, int port) { if (server.indexOf(':')>=0&&server.charAt(0)!='[') @@ -671,10 +713,34 @@ public class URIUtil else url.append(scheme).append("://").append(server); - if (port > 0 && (("http".equalsIgnoreCase(scheme) && port != 80) || ("https".equalsIgnoreCase(scheme) && port != 443))) - url.append(':').append(port); + if (port > 0) + { + switch(scheme) + { + case "http": + if (port!=80) + url.append(':').append(port); + break; + + case "https": + if (port!=443) + url.append(':').append(port); + break; + + default: + url.append(':').append(port); + } + } } + /* ------------------------------------------------------------ */ + /** + * Append scheme, host and port URI prefix, handling IPv6 address encoding and default ports

+ * @param url StringBuffer to append to + * @param scheme + * @param server + * @param port + */ public static void appendSchemeHostPort(StringBuffer url,String scheme,String server, int port) { synchronized (url) @@ -684,9 +750,53 @@ public class URIUtil else url.append(scheme).append("://").append(server); - if (port > 0 && (("http".equalsIgnoreCase(scheme) && port != 80) || ("https".equalsIgnoreCase(scheme) && port != 443))) - url.append(':').append(port); + if (port > 0) + { + switch(scheme) + { + case "http": + if (port!=80) + url.append(':').append(port); + break; + + case "https": + if (port!=443) + url.append(':').append(port); + break; + + default: + url.append(':').append(port); + } + } + } + } + + public static boolean equalsIgnoreEncodings(String uriA, String uriB) + { + int lenA=uriA.length(); + int lenB=uriB.length(); + int a=0; + int b=0; + + while (a