Implemented replacement of http protocol if current connection is https

See tracker issue 30587 and pull https://github.com/joomla/joomla-cms/pull/994 (for 3.x master)