public class GETHttpRequest extends Object
GETHttpRequest req = new GETHttpRequest();
Map<String, String> header_map = new HashMap<String, String>();
header_map.put("accept", "application/sparql-results+xml");
System.out.println(req.dereferenceURI("http://agris.fao.org/void.ttl", header_map, 0));
or
GETHttpRequest req = new GETHttpRequest();
Map<String, String> header_map = new HashMap<String, String>();
header_map.put("accept", "application/sparql-results+xml");
req.printBufferedReader(req.dereferenceURI("http://agris.fao.org/void.ttl", header_map, 0));
or
GETHttpRequest req = new GETHttpRequest();
Map<String, String> header_map = new HashMap<String, String>();
header_map.put("accept", "application/sparql-results+xml");
System.out.println(req.readBufferedReader(req.dereferenceURIReader("http://agris.fao.org/void.ttl", header_map, 5000)));
Makes HTTP requests following HTTP redirect (301, 302, 303).
String url = "http://...";
GETHttpRequest req = new GETHttpRequest();
System.out.println(req.getUrlContentWithRedirect(url), 0);
Constructor and Description |
---|
GETHttpRequest() |
Modifier and Type | Method and Description |
---|---|
String |
dereferenceURI(String uri,
Map<String,String> header_map,
int connectionTimeoutMillis)
Make a GET HTTP request setting the Mime Type in a header map.
|
BufferedReader |
dereferenceURIReader(String uri,
Map<String,String> header_map,
int connectionTimeoutMillis)
Make a GET HTTP request setting the Mime Type in a header map.
|
String |
getContentFromConnection(HttpURLConnection conn)
Extract the content from an HttpURLConnection
|
String |
getUrlContentWithRedirect(String url,
int connectionTimeoutMillis)
Extract the content from an HTTP URL with an HTTP redirect (301, 302, 303)
|
public String dereferenceURI(String uri, Map<String,String> header_map, int connectionTimeoutMillis) throws IOException
uri
- the URI of a resourceheader_map
- map of header options, nullableconnectionTimeoutMillis
- connection timeout in milliseconds, 0 means no timeoutIOException
- IOExceptionpublic BufferedReader dereferenceURIReader(String uri, Map<String,String> header_map, int connectionTimeoutMillis) throws IOException
uri
- the URI of a resourceheader_map
- map of header options, nullableconnectionTimeoutMillis
- connection timeout in milliseconds, 0 means no timeoutIOException
- IOExceptionpublic String getUrlContentWithRedirect(String url, int connectionTimeoutMillis) throws MalformedURLException, IOException
url
- the URL to readconnectionTimeoutMillis
- connection timeout in milliseconds, 0 means no timeoutIOException
- IOExceptionMalformedURLException
- MalformedURLExceptionpublic String getContentFromConnection(HttpURLConnection conn) throws IOException
conn
- the connection object to readIOException
- IOExceptionCopyright © 2016. All rights reserved.