Code cleanup

This commit is contained in:
0xboobface 2019-12-27 13:51:48 +01:00
parent f3a13a6f06
commit b72777f6fb
1 changed files with 4 additions and 5 deletions

View File

@ -213,10 +213,9 @@ public class Cam4Model extends AbstractModel {
.url(url)
.addHeader("X-Requested-With", "XMLHttpRequest")
.build();
Response response = site.getHttpClient().execute(req);
boolean success = response.isSuccessful();
response.close();
return success;
try (Response response = site.getHttpClient().execute(req)) {
return response.isSuccessful();
}
}
@Override
@ -231,9 +230,9 @@ public class Cam4Model extends AbstractModel {
// we have to use a client without any cam4 cookies here, otherwise
// this request is redirected to the login page. no idea why
try (Response response = site.getRecorder().getHttpClient().execute(req)) {
String broadCasterId = null;
if (response.isSuccessful()) {
String content = response.body().string();
String broadCasterId = null;
try {
Element tag = HtmlParser.getTag(content, "input[name=\"broadcasterId\"]");
broadCasterId = tag.attr("value");