git.hedgecode.org
/
snooker-score-api.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[LIB-10] Date and Timezone format constants from snooker.properties
[snooker-score-api.git]
/
src
/
main
/
java
/
org
/
hedgecode
/
snooker
/
request
/
AbstractRequester.java
diff --git
a/src/main/java/org/hedgecode/snooker/request/AbstractRequester.java
b/src/main/java/org/hedgecode/snooker/request/AbstractRequester.java
index
a127bb5
..
ca4466c
100644
(file)
--- a/
src/main/java/org/hedgecode/snooker/request/AbstractRequester.java
+++ b/
src/main/java/org/hedgecode/snooker/request/AbstractRequester.java
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 2017. Developed by Hedgecode.
+ * Copyright (c) 2017
-2020
. Developed by Hedgecode.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-21,6
+21,8
@@
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
/**
* Abstract Data Requester from the portal api.snooker.org.
/**
* Abstract Data Requester from the portal api.snooker.org.
@@
-30,6
+32,10
@@
import java.net.URLConnection;
public abstract class AbstractRequester implements Requester {
protected static final String API_SNOOKER_URL = "http://api.snooker.org/";
public abstract class AbstractRequester implements Requester {
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(int id) throws RequestException;
@@
-54,9
+60,12
@@
public abstract class AbstractRequester implements Requester {
try {
URL url = new URL(requestUrl);
URLConnection urlConnection = url.openConnection();
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(
BufferedReader br = new BufferedReader(
new InputStreamReader(
- urlConnection.getInputStream()
+ urlConnection.getInputStream()
, API_SNOOKER_CHARSET
)
);
String inputLine;
)
);
String inputLine;