[vlc-commits] demux: adaptive: pass referrer
Francois Cartegnie
git at videolan.org
Thu Apr 23 11:44:25 CEST 2020
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Apr 23 11:40:03 2020 +0200| [198567280cdfe427276aff5083a1e861d8e9ca4a] | committer: Francois Cartegnie
demux: adaptive: pass referrer
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=198567280cdfe427276aff5083a1e861d8e9ca4a
---
modules/demux/adaptive/http/HTTPConnection.cpp | 16 +++++++++++-----
modules/demux/adaptive/http/HTTPConnection.hpp | 1 +
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/modules/demux/adaptive/http/HTTPConnection.cpp b/modules/demux/adaptive/http/HTTPConnection.cpp
index ac2b0f84c1..f25904d352 100644
--- a/modules/demux/adaptive/http/HTTPConnection.cpp
+++ b/modules/demux/adaptive/http/HTTPConnection.cpp
@@ -29,6 +29,7 @@
#include <cstdio>
#include <sstream>
+#include <algorithm>
#include <vlc_stream.h>
using namespace adaptive::http;
@@ -73,9 +74,11 @@ HTTPConnection::HTTPConnection(vlc_object_t *p_object_, AuthStorage *auth,
char *psz_useragent = var_InheritString(p_object_, "http-user-agent");
useragent = psz_useragent ? std::string(psz_useragent) : std::string("");
free(psz_useragent);
- for(std::string::iterator it = useragent.begin(); it != useragent.end(); ++it)
- if(!std::isprint(*it))
- *it = ' ';
+ char *psz_referer = var_InheritString(p_object_, "http-referrer");
+ referer = psz_referer ? std::string(psz_referer) : std::string("");
+ free(psz_referer);
+ std::replace_if(useragent.begin(), useragent.end(), [](const char &c){return !::isprint(c);}, ' ');
+ std::replace_if(referer.begin(), referer.end(), [](const char &c){return !::isprint(c);}, ' ');
queryOk = false;
retries = 0;
authStorage = auth;
@@ -443,8 +446,11 @@ std::string HTTPConnection::buildRequestHeader(const std::string &path) const
if(!cookie.empty())
req << "Cookie: " << cookie << "\r\n";
}
- req << "Cache-Control: no-cache" << "\r\n" <<
- "User-Agent: " << useragent << "\r\n";
+ req << "Cache-Control: no-cache" << "\r\n";
+ if(!useragent.empty())
+ req << "User-Agent: " << useragent << "\r\n";
+ if(!referer.empty())
+ req << "Referer: " << referer << "\r\n";
req << extraRequestHeaders();
return req.str();
}
diff --git a/modules/demux/adaptive/http/HTTPConnection.hpp b/modules/demux/adaptive/http/HTTPConnection.hpp
index 10e8594144..630016f987 100644
--- a/modules/demux/adaptive/http/HTTPConnection.hpp
+++ b/modules/demux/adaptive/http/HTTPConnection.hpp
@@ -96,6 +96,7 @@ namespace adaptive
enum RequestStatus parseReply();
std::string readLine();
std::string useragent;
+ std::string referer;
AuthStorage *authStorage;
ConnectionParams locationparams;
More information about the vlc-commits
mailing list