@Test public void testNullFromURIGetsMergedCorrectly() throws Exception { final String into = "http: final String actual = HttpUtils.mergeQueryParameters(null, into); assertEquals(into, actual); assertSame(into, actual); }
public static String mergeQueryParameters(URI from, String into) throws URISyntaxException { if (into == null) { throw new URISyntaxException("<null>", "Cannot merge into a null URI"); } if (from == null) { return into; } final String fromQuery = from.getQuery(); final String intoQuery = URIUtils.getQuery(into); String query; if (intoQuery == null) { query = from.getQuery(); } else if (fromQuery == null) { query = intoQuery; } else { query = intoQuery; if (fromQuery.length() > 0) { query += '&' + fromQuery; } } return URIUtils.buildURIAsString(URIUtils.getScheme(into), URIUtils.getAuthority(into), URIUtils.getPath(into), query, URIUtils.getFragment(into)); }
HttpUtils { public static String mergeQueryParameters(URI from, String into) throws URISyntaxException { if (into == null) { throw new URISyntaxException("<null>", "Cannot merge into a null URI"); } if (from == null) { return into; } final String fromQuery = from.getQuery(); final String intoQuery = URIUtils.getQuery(into); String query; if (intoQuery == null) { query = from.getQuery(); } else if (fromQuery == null) { query = intoQuery; } else { query = intoQuery; if (fromQuery.length() > 0) { query += '&' + fromQuery; } } return URIUtils.buildURIAsString(URIUtils.getScheme(into), URIUtils.getAuthority(into), URIUtils.getPath(into), query, URIUtils.getFragment(into)); } }
HttpUtils { public static String mergeQueryParameters(URI from, String into) throws URISyntaxException { if (into == null) { throw new URISyntaxException("<null>", "Cannot merge into a null URI"); } if (from == null) { return into; } final String fromQuery = from.getQuery(); final String intoQuery = URIUtils.getQuery(into); String query; if (intoQuery == null) { query = from.getQuery(); } else if (fromQuery == null) { query = intoQuery; } else { query = intoQuery; if (fromQuery.length() > 0) { query += '&' + fromQuery; } } return URIUtils.buildURIAsString(URIUtils.getScheme(into), URIUtils.getAuthority(into), URIUtils.getPath(into), query, URIUtils.getFragment(into)); }  }
HttpUtils { public static String mergeQueryParameters(URI from, String into) throws URISyntaxException { if (into == null) { throw new URISyntaxException("<null>", "Cannot merge into a null URI"); } if (from == null) { return into; } final String fromQuery = from.getQuery(); final String intoQuery = URIUtils.getQuery(into); String query; if (intoQuery == null) { query = from.getQuery(); } else if (fromQuery == null) { query = intoQuery; } else { query = intoQuery; if (fromQuery.length() > 0) { query += '&' + fromQuery; } } return URIUtils.buildURIAsString(URIUtils.getScheme(into), URIUtils.getAuthority(into), URIUtils.getPath(into), query, URIUtils.getFragment(into)); }  static String getHostDomain(HttpRequestMessage httpRequest); static String getHostAndPort(HttpRequestMessage httpRequest, boolean secure); static String getHostAndPort(String authority, boolean secure); static long parseDateHeader(String header); static String formatDateHeader(long millis); static void fileRequested(IoBufferAllocatorEx<?> allocator, HttpRequestMessage httpRequest,
        HttpResponseMessage httpResponse, File requestFile); static void writeIfModified(HttpAcceptSession httpSession, File requestFile); static IoBufferEx getBufferForFile(IoBufferAllocatorEx<?> allocator, File requestFile); static boolean hasBeenModified(HttpSession session, String etag, File requestFile); static void addLastModifiedHeader(HttpSession session, File requestFile); static String getETagHeaderValue(File requestFile); static void supplyScriptAsHtml(File xdBridgeFile, long startTime, String resourcePath); static void supplyFile(File bridgeFile, long startTime, String resourcePath); static boolean canStream(HttpSession session); static String newSessionId(); static URI getRequestURI(HttpRequestMessage request, IoSession session); static URI getRequestURI(URI requestURI, String hostHeader, IoSession session); static boolean hasCloseHeader(List<String> connectionValues); static URI getTransportURI(HttpRequestMessage request, IoSession session); static boolean isChunked(String transferEncoding); static boolean isChunked(HttpResponseMessage response); static boolean isGzipped(HttpResponseMessage response); static URI getCanonicalURI(URI uri, boolean canonicalizePath); static URI getCanonicalURI(String uriString, boolean canonicalizePath); static String[] getPathComponents(URI uri); static String getAuthenticationTokenFromPath(URI uri); static boolean containsForbiddenHeaders(HttpRequestMessage request, String[] allowedHeaders); static boolean isForbiddenHeader(String header); static void excludeHeaders(HttpRequestMessage request, String[] exclusions); static void restrictHeaders(HttpRequestMessage request, String[] restrictions); static void mergeHeaders(HttpRequestMessage from, HttpRequestMessage to, String[] ignoreHeaders); static void removeValueFromHeaders(HttpRequestMessage request, String[] headerNames, String valueToRemove); static void mergeParameters(HttpRequestMessage from, HttpRequestMessage to); static void mergeCookies(HttpRequestMessage from, HttpRequestMessage to); static String mergeQueryParameters(URI from, String into); static boolean hasStreamingScheme(URI uri); static boolean hasStreamingScheme(String uri); }
HttpUtils { public static String mergeQueryParameters(URI from, String into) throws URISyntaxException { if (into == null) { throw new URISyntaxException("<null>", "Cannot merge into a null URI"); } if (from == null) { return into; } final String fromQuery = from.getQuery(); final String intoQuery = URIUtils.getQuery(into); String query; if (intoQuery == null) { query = from.getQuery(); } else if (fromQuery == null) { query = intoQuery; } else { query = intoQuery; if (fromQuery.length() > 0) { query += '&' + fromQuery; } } return URIUtils.buildURIAsString(URIUtils.getScheme(into), URIUtils.getAuthority(into), URIUtils.getPath(into), query, URIUtils.getFragment(into)); }  static String getHostDomain(HttpRequestMessage httpRequest); static String getHostAndPort(HttpRequestMessage httpRequest, boolean secure); static String getHostAndPort(String authority, boolean secure); static long parseDateHeader(String header); static String formatDateHeader(long millis); static void fileRequested(IoBufferAllocatorEx<?> allocator, HttpRequestMessage httpRequest,
        HttpResponseMessage httpResponse, File requestFile); static void writeIfModified(HttpAcceptSession httpSession, File requestFile); static IoBufferEx getBufferForFile(IoBufferAllocatorEx<?> allocator, File requestFile); static boolean hasBeenModified(HttpSession session, String etag, File requestFile); static void addLastModifiedHeader(HttpSession session, File requestFile); static String getETagHeaderValue(File requestFile); static void supplyScriptAsHtml(File xdBridgeFile, long startTime, String resourcePath); static void supplyFile(File bridgeFile, long startTime, String resourcePath); static boolean canStream(HttpSession session); static String newSessionId(); static URI getRequestURI(HttpRequestMessage request, IoSession session); static URI getRequestURI(URI requestURI, String hostHeader, IoSession session); static boolean hasCloseHeader(List<String> connectionValues); static URI getTransportURI(HttpRequestMessage request, IoSession session); static boolean isChunked(String transferEncoding); static boolean isChunked(HttpResponseMessage response); static boolean isGzipped(HttpResponseMessage response); static URI getCanonicalURI(URI uri, boolean canonicalizePath); static URI getCanonicalURI(String uriString, boolean canonicalizePath); static String[] getPathComponents(URI uri); static String getAuthenticationTokenFromPath(URI uri); static boolean containsForbiddenHeaders(HttpRequestMessage request, String[] allowedHeaders); static boolean isForbiddenHeader(String header); static void excludeHeaders(HttpRequestMessage request, String[] exclusions); static void restrictHeaders(HttpRequestMessage request, String[] restrictions); static void mergeHeaders(HttpRequestMessage from, HttpRequestMessage to, String[] ignoreHeaders); static void removeValueFromHeaders(HttpRequestMessage request, String[] headerNames, String valueToRemove); static void mergeParameters(HttpRequestMessage from, HttpRequestMessage to); static void mergeCookies(HttpRequestMessage from, HttpRequestMessage to); static String mergeQueryParameters(URI from, String into); static boolean hasStreamingScheme(URI uri); static boolean hasStreamingScheme(String uri); static Map<String, List<String>> EMPTY_HEADERS; }