feat: 物理实验系统:新增cookie验证

main
lensfrex 1 year ago
parent b7c61453c5
commit e186a0d9f0
Signed by: lensfrex
GPG Key ID: 0F69A0A2FBEE98A0
  1. 4
      mywust-core/src/main/java/cn/wustlinghang/mywust/core/request/factory/physics/PhysicsSystemRequestFactory.java
  2. 7
      mywust-core/src/main/java/cn/wustlinghang/mywust/core/request/service/auth/PhysicsLogin.java

@ -31,6 +31,10 @@ public class PhysicsSystemRequestFactory extends RequestFactory {
return makeHttpRequest(redirect, null, cookies); return makeHttpRequest(redirect, null, cookies);
} }
public static HttpRequest physicsSystemIndexRequest(String cookies) {
return makeHttpRequest(PhysicsSystemUrls.PHYSICS_SYSTEM_INDEX_URL, null, cookies);
}
public static HttpRequest physicsCourseRequest(String cookies) { public static HttpRequest physicsCourseRequest(String cookies) {
return makeHttpRequest(PhysicsSystemUrls.PHYSICS_COURSE_API, null, cookies); return makeHttpRequest(PhysicsSystemUrls.PHYSICS_COURSE_API, null, cookies);
} }

@ -70,4 +70,11 @@ public class PhysicsLogin {
return loginCookies; return loginCookies;
} }
public boolean checkCookie(String cookie, RequestClientOption option) throws IOException {
HttpRequest testRequest = PhysicsSystemRequestFactory.physicsSystemIndexRequest(cookie);
HttpResponse testResponse = requester.get(testRequest, option);
return testResponse.getStatusCode() != HttpResponse.HTTP_REDIRECT_302;
}
} }
Loading…
Cancel
Save