I am planning to do measurements on the network traffic when playing videos. This will of course only work when the video is transmitted over HTTP instead of HTTPS.
The YouTube iframe API however always switches to HTTPS downloads, despite me loading the API from http://
and specifying a YouTube URL with http://
too. You can use the example here to test the player. As you can see it always switches to https://videoplayback...
, which is what I want to disable.
How do I force it to use HTTP instead of HTTPS? This is sort of the inverse question of this. I guess it would come down to hacking some functions into the current JS.
In the Widget API I can see calls like:
b = 0 == c.indexOf("https:") ? [c] : b.d ? [c.replace("http:", "https:")] : b.k ? [c] : [c, c.replace("http:", "https:")];
and
if (this.d = !!("https:" == document.location.protocol || a && 0 == a.src.indexOf("https:"))) {
a = [this.j, window.YTConfig || {}, this.defaults];
for (var b = 0; b < a.length; b++) a[b].host && (a[b].host = a[b].host.replace("http://", "https://"))
}
but I have no clue where to override this in the context of the YT
and YT.Player
objects, or if I can even do so.
To those wondering whether this might be impossible on the server-side: Note that YouTube does work with HTTP only. If you are not logged into YouTube and go to http://youtube.com
, your video playbacks will be in HTTP, not HTTPS.
YouTube is now forcing https via 301 redirection. Sometime ago it was not the case. Redirection was just a user setting stored in cookie.
You can try changing your User Agent and/or test on m.youtube.com but the traffic measurements may not be accurate since it's different domain and protocol and youtube can have separate priorities.
Changing User Agent is simple in Chrome Dev Tools (phone icon in top left corner).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With