diff --git a/common/src/main/java/ctbrec/io/HttpConstants.java b/common/src/main/java/ctbrec/io/HttpConstants.java index 15c95891..fb706566 100644 --- a/common/src/main/java/ctbrec/io/HttpConstants.java +++ b/common/src/main/java/ctbrec/io/HttpConstants.java @@ -4,12 +4,15 @@ public class HttpConstants { public static final String ACCEPT = "Accept"; public static final String ACCEPT_LANGUAGE = "Accept-Language"; + public static final String CACHE_CONTROL = "Cache-Control"; public static final String CONNECTION = "Connection"; public static final String CONTENT_TYPE = "Content-Type"; public static final String COOKIE = "Cookie"; public static final String KEEP_ALIVE = "keep-alive"; public static final String MIMETYPE_APPLICATION_JSON = "application/json"; + public static final String NO_CACHE = "no-cache"; public static final String ORIGIN = "Origin"; + public static final String PRAGMA = "Pragma"; public static final String REFERER = "Referer"; public static final String USER_AGENT = "User-Agent"; public static final String XML_HTTP_REQUEST = "XMLHttpRequest"; diff --git a/common/src/main/java/ctbrec/sites/cam4/Cam4Model.java b/common/src/main/java/ctbrec/sites/cam4/Cam4Model.java index 9c12faf1..ad0f79f3 100644 --- a/common/src/main/java/ctbrec/sites/cam4/Cam4Model.java +++ b/common/src/main/java/ctbrec/sites/cam4/Cam4Model.java @@ -141,6 +141,8 @@ public class Cam4Model extends AbstractModel { .header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent) .header(ACCEPT, "*/*") .header(ACCEPT_LANGUAGE, "*") + .header(CACHE_CONTROL, NO_CACHE) + .header(PRAGMA, NO_CACHE) .header(REFERER, getUrl()) .build(); // @formatter:on try (Response response = site.getHttpClient().execute(req)) { @@ -161,7 +163,15 @@ public class Cam4Model extends AbstractModel { } private String loadModelPage() throws IOException { - Request req = new Request.Builder().url(getUrl()).build(); + Request req = new Request.Builder() + .url(getUrl()) + .header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent) + .header(ACCEPT, "text/html") + .header(ACCEPT_LANGUAGE, "en") + .header(CACHE_CONTROL, NO_CACHE) + .header(PRAGMA, NO_CACHE) + .header(REFERER, site.getBaseUrl()) + .build(); try (Response response = site.getHttpClient().execute(req)) { if (response.isSuccessful()) { return response.body().string();