Example #1
0
 public static int putUrlAsString(String content, String url) throws HTTPException {
   HTTPSession session = new HTTPSession(url);
   HTTPMethod m = HTTPMethod.Put(session);
   m.setRequestContentAsString(content);
   int status = m.execute();
   m.close();
   return status;
 }
Example #2
0
 /** Close the session. This implies closing any open methods. */
 public synchronized void close() {
   if (closed) return; // multiple calls ok
   while (methodList.size() > 0) {
     HTTPMethod m = methodList.get(0);
     m.close(); // forcibly close; will invoke removemethod().
   }
   closed = true;
 }
Example #3
0
 public static String getUrlAsString(String url) throws HTTPException {
   HTTPSession session = new HTTPSession(url);
   HTTPMethod m = HTTPMethod.Get(session);
   int status = m.execute();
   String content = null;
   if (status == 200) {
     content = m.getResponseAsString();
   }
   m.close();
   return content;
 }