Skip to content

Commit d2e4cc2

Browse files
committed
Verify HTTP result
IB-4055
1 parent 16d10f9 commit d2e4cc2

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/crypto/Connect.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ class Connect
3535
struct Result {
3636
std::string result, content;
3737
std::map<std::string,std::string> headers;
38+
bool isOK() const
39+
{
40+
return result.find("200") != std::string::npos;
41+
}
3842
bool isRedirect() const
3943
{
4044
return result.find("301") != std::string::npos ||

src/crypto/TSL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ TSL::Result TSL::parse(const string &url, const vector<X509Cert> &certs,
259259
Connect::Result r = Connect(url, "GET", timeout).exec({{"Accept-Encoding", "gzip"}}, vector<unsigned char>());
260260
if(r.isRedirect())
261261
r = Connect(r.headers["Location"], "GET", timeout).exec({{"Accept-Encoding", "gzip"}}, vector<unsigned char>());
262+
if(!r.isOK() || r.content.empty())
263+
THROW("HTTP status code is not 200 or content is empty");
262264
file << r.content;
263265
file.close();
264266

0 commit comments

Comments
 (0)