Package opendap.dap.http

Examples of opendap.dap.http.HTTPMethodStream


  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;
View Full Code Here

TOP

Related Classes of opendap.dap.http.HTTPMethodStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.