forked from j62/ctbrec
1
0
Fork 0

Use CamrecApplication's http client for cam4 unfollow requests

If the cam4 http client is used, the request does not work. Must have
something to do with the authentication cookies. No idea!
This commit is contained in:
0xboobface 2018-11-14 14:19:26 +01:00
parent 037061531e
commit 8e1aabc7b7
1 changed files with 9 additions and 2 deletions

View File

@ -26,6 +26,7 @@ import ctbrec.AbstractModel;
import ctbrec.Config;
import ctbrec.recorder.download.StreamSource;
import ctbrec.sites.Site;
import ctbrec.ui.CamrecApplication;
import ctbrec.ui.HtmlParser;
import okhttp3.FormBody;
import okhttp3.Request;
@ -177,8 +178,14 @@ public class Cam4Model extends AbstractModel {
public boolean unfollow() throws IOException {
// get model user id
String url = site.getBaseUrl() + '/' + getName();
Request req = new Request.Builder().url(url).build();
Response response = site.getHttpClient().execute(req, true);
Request req = new Request.Builder()
.url(url)
.addHeader("X-Requested-With", "XMLHttpRequest")
.build();
// we have to use a client without any cam4 cookies here, otherwise
// this request is redirected to the login page. no idea why
Response response = CamrecApplication.httpClient.execute(req);
String broadCasterId = null;
if(response.isSuccessful()) {
String content = response.body().string();