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; }
/** Close the session. This implies closing any open methods. */ public synchronized void close() { if (this.closed) return; // multiple calls ok while (methodList.size() > 0) { HTTPMethod m = methodList.get(0); m.close(); // forcibly close; will invoke removemethod(). } closed = true; }
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; }