if (showRequest) System.out.printf(" CdmRemote request %s%n", url); try (HTTPMethod method = HTTPFactory.Get(httpClient, url)) { method.setFollowRedirects(true); int statusCode = method.execute();
public static FeatureType isCdmrfEndpoint(String endpoint) throws IOException { HTTPSession httpClient = HTTPFactory.newSession(endpoint); String url = endpoint + "?req=featureType"; // get the header try (HTTPMethod method = HTTPFactory.Get(httpClient, url)) { method.setFollowRedirects(true); int statusCode = method.execute(); if (statusCode != 200) return null; String content = method.getResponseAsString(); return FeatureType.getType(content); } catch (Throwable t) { t.printStackTrace(); return null; } }
String url = remoteURI + "?req=header"; method = HTTPFactory.Get(httpClient, url); method.setFollowRedirects(true); if (showRequest) System.out.printf("CdmRemote request %s %n", url); int statusCode = method.execute();
method.setFollowRedirects(true); method.setRange(pos,end); doConnect(method);
try { method = HTTPFactory.Get(session); method.setFollowRedirects(true); method.setRequestHeader("Range", "bytes=" + pos + "-" + end); doConnect(method);
public CoverageCollection open() throws IOException { long start = System.currentTimeMillis(); HTTPSession httpClient = HTTPFactory.newSession(endpoint); String url = endpoint + "?req=header"; CdmrCoverageReader reader = new CdmrCoverageReader(endpoint, httpClient); // get the header try (HTTPMethod method = HTTPFactory.Get(httpClient, url)) { method.setFollowRedirects(true); if (showRequest) System.out.printf("CdmrFeature request %s %n", url); int statusCode = method.execute(); if (statusCode == 404) throw new FileNotFoundException(getErrorMessage(method)); if (statusCode >= 300) throw new IOException(getErrorMessage(method)); InputStream is = method.getResponseAsStream(); byte[] b = new byte[4]; NcStream.readFully(is, b); if (!NcStream.test(b, NcStream.MAGIC_HEADERCOV)) throw new IOException("Data corrupted on " + endpoint); // header message int msize = NcStream.readVInt(is); byte[] m = new byte[msize]; NcStream.readFully(is, m); CdmrFeatureProto.CoverageDataset proto = CdmrFeatureProto.CoverageDataset.parseFrom(m); CoverageCollection gridDataset = decodeHeader(proto, reader); long took = System.currentTimeMillis() - start; if (showRequest) System.out.printf(" took %d msecs %n", took); return gridDataset; } }
private HTTPMethod getHttpResponse(URI uri) throws IOException { HTTPMethod method = null; try { method = HTTPFactory.Get(uri.toString()); method.getSession().setConnectionTimeout(this.connectionTimeout); method.getSession().setSoTimeout(this.socketTimeout); method.setFollowRedirects(this.followRedirects); method.setRequestHeader("Accept-Encoding", this.contentEncoding); method.execute(); int statusCode = method.getStatusCode(); if (statusCode == 200 || statusCode == 201) { return method; } method.execute(); return method; } catch (Throwable t) { if (method != null) method.close(); throw t; } } }