Skip to content

Commit

Permalink
Verify HTTP result
Browse files Browse the repository at this point in the history
IB-4055
  • Loading branch information
metsma committed Aug 24, 2015
1 parent 16d10f9 commit d2e4cc2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmake
4 changes: 4 additions & 0 deletions src/crypto/Connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class Connect
struct Result {
std::string result, content;
std::map<std::string,std::string> headers;
bool isOK() const
{
return result.find("200") != std::string::npos;
}
bool isRedirect() const
{
return result.find("301") != std::string::npos ||
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/TSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ TSL::Result TSL::parse(const string &url, const vector<X509Cert> &certs,
Connect::Result r = Connect(url, "GET", timeout).exec({{"Accept-Encoding", "gzip"}}, vector<unsigned char>());
if(r.isRedirect())
r = Connect(r.headers["Location"], "GET", timeout).exec({{"Accept-Encoding", "gzip"}}, vector<unsigned char>());
if(!r.isOK() || r.content.empty())
THROW("HTTP status code is not 200 or content is empty");
file << r.content;
file.close();

Expand Down

0 comments on commit d2e4cc2

Please sign in to comment.