我每次this現場進行OKHttp POST請求的響應代碼是302和響應主體是:OKHttp柄302
<html>
<head>
<title>Object moved</title>
</head>
<body>
<h2>Object moved to <a href="/GradebookSummary.aspx">here</a>.
</h2>
</body>
</html>
這裏是我的代碼:
OkHttpClient client = new OkHttpClient().newBuilder()
.followRedirects(false)
.followSslRedirects(false)
.build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "checkCookiesEnabled=true&checkMobileDevice=false&checkStandaloneMode=false&checkTabletDevice=false&portalAccountUsername=username&portalAccountPassword=password");
Request request = new Request.Builder()
.url("https://hac.chicousd.org/LoginParent.aspx?page=GradebookSummary.aspx")
.post(body)
.addHeader("content-type", "application/x-www-form-urlencoded")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
我的問題是:我如何處理能夠前往新位置的響應?
我有同樣的問題,不適合我:/ –