public static InputStream sendQuery(String remoteURI, String query) throws IOException {
HTTPSession session = null;
HTTPMethod method = null;
HTTPMethodStream hmstream = null;
InputStream stream = null;
int statusCode = 0;
StringBuilder sbuff = new StringBuilder(remoteURI);
sbuff.append("?");
sbuff.append(query);
if (showRequest)
System.out.println(" CdmRemote sendQuery=" + sbuff);
try {
try {
session = new HTTPSession();
method = session.newMethodGet(sbuff.toString());
statusCode = method.execute();
} catch (HTTPException he) {
throw new IOException(he);
}
if (statusCode == 404)
throw new FileNotFoundException(method.getPath() + " " + method.getStatusLine());
if (statusCode >= 300)
throw new IOException(method.getPath() + " " + method.getStatusLine());
stream = method.getResponseBodyAsStream();
hmstream = new HTTPMethodStream(session, method, stream);
return hmstream;
} catch (IOException ioe) {
if (session != null) session.close();
throw ioe;