ui/src/main/java/ucar/nc2/ui/widget/URLDumpPane.java
@Urlencoded
  private void openURL2(String urlString, Command cmd) {

    HTTPMethod m;

    try (HTTPSession httpclient = HTTPFactory.newSession(urlString)) {
      /* you might think this works, but it doesnt:
      URI raw = new URI(urlString.trim());
      appendLine("raw scheme= " + raw.getScheme() + "\n auth= " + raw.getRawAuthority() + "\n path= " + raw.getRawPath() +
           "\n query= " + raw.getRawQuery() + "\n fragment= " + raw.getRawFragment()+"\n");

      URI url = new URI(raw.getScheme(), raw.getRawAuthority(),
              URIUtil.encodePath(raw.getRawPath()),
              URIUtil.encodeQuery(raw.getRawQuery()),
              raw.getRawFragment());
      appendLine("encoded scheme= " + url.getScheme() + "\n auth= " + url.getAuthority() + "\n path= " + url.getPath() +
           "\n query= " + url.getQuery() + "\n fragment= " + url.getFragment()+"\n");
      urlString = url.toString();
              */

      //urlString = URLnaming.escapeQuery(urlString);
      if (cmd == Command.GET)
          m = HTTPFactory.Get(httpclient,urlString);
      else if (cmd == Command.HEAD)
          m = HTTPFactory.Head(httpclient,urlString);
      else if (cmd == Command.OPTIONS)
          m = HTTPFactory.Options(httpclient,urlString);
      else if (cmd == Command.PUT) {
          m = HTTPFactory.Put(httpclient,urlString);
          m.setRequestContent(new StringEntity(ta.getText())); // was  setRequestContentAsString(ta.getText());
      } else {
          throw new IOException("Unsupported command: " + cmd);
      }

      m.setCompression("gzip,deflate");

      /* FIX
      appendLine("HttpClient " + m.getName() + " " + urlString);

      appendLine("   do Authentication= " + m.getDoAuthentication());
      appendLine("   follow Redirects= " + m.getFollowRedirects());


      appendLine("   cookie policy= " + p.getCookiePolicy());
      appendLine("   http version= " + p.getVersion().toString());
      appendLine("   timeout (msecs)= " + p.getSoTimeout());
      appendLine("   virtual host= " + p.getVirtualHost());
      */
      printHeaders("Request Headers = ", m.getRequestHeaders());
      appendLine(" ");

      m.execute();

      printHeaders("Request Headers2 = ", m.getRequestHeaders());
      appendLine(" ");

      appendLine("Status = " + m.getStatusCode() + " " + m.getStatusText());
      appendLine("Status Line = " + m.getStatusLine());
      printHeaders("Response Headers = ", m.getResponseHeaders());
      if (cmd == Command.GET) {
        appendLine("\nResponseBody---------------");

        String charset = m.getResponseCharSet();
        if (charset == null) charset = CDM.UTF8;
        String contents = null;

        // check for deflate and gzip compression
        Header h = m.getResponseHeader("content-encoding");
        String encoding = (h == null) ? null : h.getValue();

        if (encoding != null && encoding.equals("deflate")) {
          byte[] body = m.getResponseAsBytes();
          if (body != null) {
            InputStream is = new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(body)), 10000);
            contents = IO.readContents(is, charset);
            double ratio = (double) contents.length() / body.length;
            appendLine("  deflate encoded=" + body.length + " decoded=" + contents.length() + " ratio= " + ratio);
          }

        } else if (encoding != null && encoding.equals("gzip")) {
          byte[] body = m.getResponseAsBytes();
          if (body != null) {
            InputStream is = new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(body)), 10000);
            contents = IO.readContents(is, charset);
            double ratio = (double) contents.length() / body.length;
            appendLine("  gzip encoded=" + body.length + " decoded=" + contents.length() + " ratio= " + ratio);
          }

        } else {
          byte[] body = m.getResponseAsBytes(50 * 1000); // max 50 Kbytes
          contents = (body == null) ? "" : new String(body, charset);
        }

        if (contents != null) {
          if (contents.length() > 50 * 1000) // limit contents
            contents = contents.substring(0, 50 * 1000);
          appendLine(contents);
        }

      } else if (cmd == Command.OPTIONS)
        printSet("AllowedMethods = ", HTTPFactory.getAllowedMethods());

    } catch (IOException e) {
      StringWriter sw = new StringWriter(5000);
      e.printStackTrace(new PrintWriter(sw));
      appendLine(sw.toString());
    }
  }
@Urlencoded
  private void openURL2(String urlString, Command cmd) {

    HTTPMethod m;

    try (HTTPSession httpclient = HTTPFactory.newSession(urlString)) {
      /* you might think this works, but it doesnt:
      URI raw = new URI(urlString.trim());
      appendLine("raw scheme= " + raw.getScheme() + "\n auth= " + raw.getRawAuthority() + "\n path= " + raw.getRawPath() +
           "\n query= " + raw.getRawQuery() + "\n fragment= " + raw.getRawFragment()+"\n");

      URI url = new URI(raw.getScheme(), raw.getRawAuthority(),
              URIUtil.encodePath(raw.getRawPath()),
              URIUtil.encodeQuery(raw.getRawQuery()),
              raw.getRawFragment());
      appendLine("encoded scheme= " + url.getScheme() + "\n auth= " + url.getAuthority() + "\n path= " + url.getPath() +
           "\n query= " + url.getQuery() + "\n fragment= " + url.getFragment()+"\n");
      urlString = url.toString();
              */

      //urlString = URLnaming.escapeQuery(urlString);
      if (cmd == Command.GET)
          m = HTTPFactory.Get(httpclient,urlString);
      else if (cmd == Command.HEAD)
          m = HTTPFactory.Head(httpclient,urlString);
      else if (cmd == Command.OPTIONS)
          m = HTTPFactory.Options(httpclient,urlString);
      else if (cmd == Command.PUT) {
          m = HTTPFactory.Put(httpclient,urlString);
          m.setRequestContent(new StringEntity(ta.getText())); // was  setRequestContentAsString(ta.getText());
      } else {
          throw new IOException("Unsupported command: " + cmd);
      }

      m.setCompression("gzip,deflate");

      /* FIX
      appendLine("HttpClient " + m.getName() + " " + urlString);

      appendLine("   do Authentication= " + m.getDoAuthentication());
      appendLine("   follow Redirects= " + m.getFollowRedirects());


      appendLine("   cookie policy= " + p.getCookiePolicy());
      appendLine("   http version= " + p.getVersion().toString());
      appendLine("   timeout (msecs)= " + p.getSoTimeout());
      appendLine("   virtual host= " + p.getVirtualHost());
      */
      printHeaders("Request Headers = ", m.getRequestHeaders());
      appendLine(" ");

      m.execute();

      printHeaders("Request Headers2 = ", m.getRequestHeaders());
      appendLine(" ");

      appendLine("Status = " + m.getStatusCode() + " " + m.getStatusText());
      appendLine("Status Line = " + m.getStatusLine());
      printHeaders("Response Headers = ", m.getResponseHeaders());
      if (cmd == Command.GET) {
        appendLine("\nResponseBody---------------");

        String charset = m.getResponseCharSet();
        if (charset == null) charset = CDM.UTF8;
        String contents = null;

        // check for deflate and gzip compression
        Header h = m.getResponseHeader("content-encoding");
        String encoding = (h == null) ? null : h.getValue();

        if (encoding != null && encoding.equals("deflate")) {
          byte[] body = m.getResponseAsBytes();
          if (body != null) {
            InputStream is = new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(body)), 10000);
            contents = IO.readContents(is, charset);
            double ratio = (double) contents.length() / body.length;
            appendLine("  deflate encoded=" + body.length + " decoded=" + contents.length() + " ratio= " + ratio);
          }

        } else if (encoding != null && encoding.equals("gzip")) {
          byte[] body = m.getResponseAsBytes();
          if (body != null) {
            InputStream is = new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(body)), 10000);
            contents = IO.readContents(is, charset);
            double ratio = (double) contents.length() / body.length;
            appendLine("  gzip encoded=" + body.length + " decoded=" + contents.length() + " ratio= " + ratio);
          }

        } else {
          byte[] body = m.getResponseAsBytes(50 * 1000); // max 50 Kbytes
          contents = (body == null) ? "" : new String(body, charset);
        }

        if (contents != null) {
          if (contents.length() > 50 * 1000) // limit contents
            contents = contents.substring(0, 50 * 1000);
          appendLine(contents);
        }

      } else if (cmd == Command.OPTIONS)
        printSet("AllowedMethods = ", HTTPFactory.getAllowedMethods());

    } catch (IOException e) {
      StringWriter sw = new StringWriter(5000);
      e.printStackTrace(new PrintWriter(sw));
      appendLine(sw.toString());
    }
  }
Uses apache commons HttpClient