{
URL url = getUrl(ids);
+ BufferedReader reader = getHttpResponse(url, ids);
+ FileParse fp = new FileParse(reader, url.toString(), "HTTP_POST");
+ return fp;
+ }
+
+ /**
+ * Writes the HTTP request and gets the response as a reader.
+ *
+ * @param url
+ * @param ids
+ * written as Json POST body if more than one
+ * @return
+ * @throws IOException
+ * if response code was not 200, or other I/O error
+ */
+ protected BufferedReader getHttpResponse(URL url, List<String> ids)
+ throws IOException
+ {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
/*
* note: a GET request for an invalid id returns an error code e.g. 415
* but POST request returns 200 and an empty Fasta response
*/
- throw new RuntimeException(
+ throw new IOException(
"Response code was not 200. Detected response was "
+ responseCode);
}
BufferedReader reader = null;
reader = new BufferedReader(new InputStreamReader(response, "UTF-8"));
- FileParse fp = new FileParse(reader, url.toString(), "HTTP_POST");
- return fp;
+ return reader;
}
/**