/** @see org.geotools.data.ows.HTTPClient#get(java.net.URL) */ public HTTPResponse get(final URL url) throws IOException { URLConnection connection = openConnection(url); if (connection instanceof HttpURLConnection) { ((HttpURLConnection) connection).setRequestMethod("GET"); } connection.connect(); return new SimpleHTTPResponse(connection); }
/** * @see org.geotools.data.ows.HTTPClient#post(java.net.URL, java.io.InputStream, * java.lang.String) */ public HTTPResponse post( final URL url, final InputStream postContent, final String postContentType) throws IOException { URLConnection connection = openConnection(url); if (connection instanceof HttpURLConnection) { ((HttpURLConnection) connection).setRequestMethod("POST"); } connection.setDoOutput(true); if (postContentType != null) { connection.setRequestProperty("Content-type", postContentType); } connection.connect(); OutputStream outputStream = connection.getOutputStream(); try { byte[] buff = new byte[512]; int count; while ((count = postContent.read(buff)) > -1) { outputStream.write(buff, 0, count); } } finally { outputStream.flush(); outputStream.close(); } return new SimpleHTTPResponse(connection); }
/** * @see org.geotools.data.ows.HTTPClient#get(java.net.URL) */ public HTTPResponse get(final URL url) throws IOException { HttpURLConnection connection = openConnection(url); connection.setRequestMethod("GET"); connection.connect(); return new SimpleHTTPResponse(connection); }
/** * @see org.geotools.data.ows.HTTPClient#post(java.net.URL, java.io.InputStream, * java.lang.String) */ public HTTPResponse post(final URL url, final InputStream postContent, final String postContentType) throws IOException { HttpURLConnection connection = openConnection(url); connection.setRequestMethod("POST"); connection.setDoOutput(true); if (postContentType != null) { connection.setRequestProperty("Content-type", postContentType); } connection.connect(); OutputStream outputStream = connection.getOutputStream(); try { byte[] buff = new byte[512]; int count; while ((count = postContent.read(buff)) > -1) { outputStream.write(buff, 0, count); } } finally { outputStream.flush(); outputStream.close(); } return new SimpleHTTPResponse(connection); }