Example #1
0
  @Test
  @Category(NeedsExternalResource.class)
  public void testUTF8Stream() throws Exception {
    pass = true;

    String catalogName = "http://" + TestDir.remoteTestServer + "/thredds/catalog.xml";

    try (HTTPMethod m = HTTPFactory.Get(catalogName)) {
      int statusCode = m.execute();
      System.out.printf("status = %d%n", statusCode);
      try {
        String content = m.getResponseAsString("ASCII");
        System.out.printf("cat = %s%n", content);
      } catch (Throwable t) {
        t.printStackTrace();
        assert false;
      }
    }
  }
Example #2
0
 protected boolean checkServer(String candidate) {
   if (candidate == null) return false;
   /* requires httpclient4
           int savecount = HTTPSession.getRetryCount();
           HTTPSession.setRetryCount(1);
   */
   // See if the sourceurl is available by trying to get the DSR
   System.err.print("Checking for sourceurl: " + candidate);
   try {
     try (HTTPMethod method = HTTPFactory.Get(candidate)) {
       method.execute();
       String s = method.getResponseAsString();
       System.err.println(" ; found");
       return true;
     }
   } catch (IOException ie) {
     System.err.println(" ; fail");
     return false;
   } finally {
     // requires httpclient4            HTTPSession.setRetryCount(savecount);
   }
 }