ui/src/main/java/ucar/nc2/ui/widget/URLDumpPane.java
private HTTPMethod processMethod (HTTPSession httpclient, String url, Command cmd) throws HTTPException, UnsupportedEncodingException {
      HTTPMethod m = null;
      if (cmd == Command.GET)
          m = HTTPFactory.Get(httpclient,url);
      else if (cmd == Command.HEAD)
          m = HTTPFactory.Head(httpclient,url);
      else if (cmd == Command.OPTIONS)
          m = HTTPFactory.Options(httpclient,url);
      else if (cmd == Command.PUT) {
          m = HTTPFactory.Put(httpclient,url);
          m.setRequestContent(new StringEntity(ta.getText())); // was  setRequestContentAsString(ta.getText());
      }

      return m;
  }
private HTTPMethod processMethod (HTTPSession httpclient, String url, Command cmd) throws HTTPException, UnsupportedEncodingException {
      HTTPMethod m = null;
      if (cmd == Command.GET)
          m = HTTPFactory.Get(httpclient,url);
      else if (cmd == Command.HEAD)
          m = HTTPFactory.Head(httpclient,url);
      else if (cmd == Command.OPTIONS)
          m = HTTPFactory.Options(httpclient,url);
      else if (cmd == Command.PUT) {
          m = HTTPFactory.Put(httpclient,url);
          m.setRequestContent(new StringEntity(ta.getText())); // was  setRequestContentAsString(ta.getText());
      }

      return m;
  }
private HTTPMethod processMethod ( HTTPSession httpclient , String url , Command cmd ) throws HTTPException , UnsupportedEncodingException { HTTPMethod m = null ; if ( cmd == Command . GET ) m = HTTPFactory . Get ( httpclient , url ) ; else if ( cmd == Command . HEAD ) m = HTTPFactory . Head ( httpclient , url ) ; else if ( cmd == Command . OPTIONS ) m = HTTPFactory . Options ( httpclient , url ) ; else if ( cmd == Command . PUT ) { m = HTTPFactory . Put ( httpclient , url ) ; m . setRequestContent ( new StringEntity ( ta . getText ( ) ) ) ; // was  setRequestContentAsString(ta.getText());
 } return m ; }
/*
/////////////////////////////////////////////////////
Uses apache HttpComponents

private void openClient(String urlString, Command cmd) {
HttpEntity entity = null;
try {
org.apache.http.client.HttpClient httpclient = new DefaultHttpClient();

request
HttpGet httpget = new HttpGet(urlString);
appendLine("Request: " + httpget.getRequestLine());

HttpParams params = httpget.getParams();
appendLine("Params: ");
showParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, params);
showParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET, params);
showParameter(CoreProtocolPNames.ORIGIN_SERVER, params);
showParameter(CoreProtocolPNames.PROTOCOL_VERSION, params);
showParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, params);
showParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, params);
showParameter(CoreProtocolPNames.USER_AGENT, params);
showParameter(CoreProtocolPNames.WAIT_FOR_CONTINUE, params);

response
BasicHttpContext localContext = new BasicHttpContext();
HttpResponse response = httpclient.execute(httpget, localContext);

appendLine("\nHttpContext: " + localContext);
showAtribute(ExecutionContext.HTTP_CONNECTION, localContext);
showAtribute(ExecutionContext.HTTP_PROXY_HOST, localContext);
showAtribute(ExecutionContext.HTTP_REQ_SENT, localContext);
showAtribute(ExecutionContext.HTTP_REQUEST, localContext);
showAtribute(ExecutionContext.HTTP_RESPONSE, localContext);
showAtribute(ExecutionContext.HTTP_TARGET_HOST, localContext);

HttpRequest req = (HttpRequest) localContext.getAttribute(ExecutionContext.HTTP_REQUEST);
appendLine("\nRequest Headers:");
HeaderIterator it = req.headerIterator();
while (it.hasNext()) {
appendLine(" " + it.next().toString());
}

appendLine("\nResponse Headers:");
it = response.headerIterator();
while (it.hasNext()) {
appendLine(" " + it.next().toString());
}

content
entity = response.getEntity();
if (entity != null) {
String contents = EntityUtils.toString(entity);
if (contents.length() > 50 * 1000)
contents = contents.substring(0, 50 * 1000);
appendLine("\nContent:");
appendLine(contents);
}

} catch (Exception e) {
ByteArrayOutputStream bos = new ByteArrayOutputStream(5000);
e.printStackTrace(new PrintStream(bos));
appendLine(bos.toString());

} finally {
if (entity != null) try {
entity.consumeContent();

} catch (IOException e) {
ByteArrayOutputStream bos = new ByteArrayOutputStream(5000);
e.printStackTrace(new PrintStream(bos));
appendLine(bos.toString());
}
}
}

private void showAtribute(String key, HttpContext localContext) {
Object value = localContext.getAttribute(key);
if (null != value)
appendLine(" " + key + ": " + value);
}

private void showParameter(String key, HttpParams params) {
Object value = params.getParameter(key);
if (null != value)
appendLine(" " + key + ": " + value);
}
/ * ///////////////////////////////////////////////////// Uses apache HttpComponents