forked from j62/ctbrec
Add cache control headers to Cam4 requests
This commit is contained in:
parent
e90ef22fa1
commit
43d8b9d2de
|
@ -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";
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue