long DLL_EXPORT getURLContentLength(const char * host, const char * page) {
sf::Http http;
http.SetHost(host);
sf::Http::Request request(page);
sf::Http::Response response = http.SendRequest(request);
sf::Http::Response::Status status = response.GetStatus();
std::string str;
if (status == sf::Http::Response::Ok) {
str = response.GetField("Content-Length");
} else {
str = "Request Error.";
}
std::cout << str;
}
This is the Function, the call is :
getURLContentLenght("
http://www.sfml-dev.org", "features.php");
If I request the Pages Content, it works correctly, but I simply don't get the content-length.
I want do modify that function to only request the header, then getting the Content-Lenght: Field.
Right now I have to request the whole page once, then get the contentlength by str.length() in C++, and then I have to request the Content again ( with a getURLContent function ).