protected static final String API_SNOOKER_URL = "http://api.snooker.org/";
protected static final Charset API_SNOOKER_CHARSET = StandardCharsets.UTF_8;
+ private static final String API_SNOOKER_HEADER_NAME = "X-Requested-By";
+ private static final String API_SNOOKER_HEADER_VALUE = "Hedgecode";
+
protected abstract String getRequestUrl(int id) throws RequestException;
protected abstract String getRequestUrl(RequestParams params) throws RequestException;
try {
URL url = new URL(requestUrl);
URLConnection urlConnection = url.openConnection();
+ urlConnection.setRequestProperty(
+ API_SNOOKER_HEADER_NAME, API_SNOOKER_HEADER_VALUE
+ );
BufferedReader br = new BufferedReader(
new InputStreamReader(
urlConnection.getInputStream(), API_SNOOKER_CHARSET