HTTPS detection is not reliable. It uses $_SERVER['HTTPS'] == 'on', but according to PHP docs :
'HTTPS' Set to a non-empty value if the script was queried through the HTTPS protocol.
This maybe problem e.g. when mediawiki is running on Amazon cloud through HTTPS, their load balancer sets the HTTPS to '1'.
Also the detection code suppose the HTTPS to be SSL on port 443, but IMHO it can be also TLS on port 80 and injecting the explicit port in this case also breaks things for me (Amazon/HTTPS/Firefox). Attached is the fix for mediawiki 1.16. It seems that the latest mediawiki 1.20.3 is also affected, but the code is slightly different there.
This problem results in e.g. inability to save the user preferences.