Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/HttpCommunicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ String decompressGZIPStream(WiFiClient *gzipStream){
return unzipped;
}

response getRequest(const String &url)
response getRequest(const String &url, const char* rootca)
{
HTTPClient http;
response response;
Expand All @@ -122,9 +122,16 @@ response getRequest(const String &url)
const char *headerKeys[headerKeysCount] = {"Content-Encoding"};
http.collectHeaders(headerKeys, headerKeysCount);

http.begin(url.c_str());
response.code = http.GET();
if (response.code > 0)
if(rootca == NULL || url.indexOf("https") != 0){
log_i("HTTP");
http.begin(convertHTTPStoHTTP(url).c_str());
}else{
log_i("HTTPS");
http.begin(url.c_str(), rootca);
}
int httpCode = http.GET();
response.code = httpCode;
if (httpCode > 0)
{
log_i("CODE: %d", response.code);
if (response.code == HTTP_CODE_OK)
Expand Down Expand Up @@ -230,11 +237,11 @@ enum ParseResponseStatus parseResponse(const response &res, uint8_t &duration, S
if (isCode3XX(httpCode))
{
m3u8Urls.pop();
m3u8Urls.push(convertHTTPStoHTTP(newUrl));
m3u8Urls.push(newUrl);
}
else if (!m3u8Urls.search(newUrl))
{
m3u8Urls.push(convertHTTPStoHTTP(newUrl));
m3u8Urls.push(newUrl);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/HttpCommunicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ typedef struct{
String convertHTTPStoHTTP(const String &url);
bool isCode3XX(const int &code);
String decompressGZIPStream(WiFiClient *gzipStream);
response getRequest(const String &url);
response getRequest(const String &url, const char *rootca = NULL);
enum ParseResponseStatus parseResponse(const response &res, uint8_t &duration, Stack<String> &m3u8Urls, IndexQueue<String> &aacUrls);