first check if a private key exists, if not it is always a recovery szenario
Append port to trusted domain in case it's not 80 or 443

Ref https://github.com/owncloud/core/pull/10584#issuecomment-54677059

Backport of 2590a4dc85cb23311a9000770bf506c3953d0b04 from master
Do only follow HTTP and HTTPS redirects

We do not want to follow redirects to other protocols since they might allow an adversary to bypass network restrictions. (i.e. a redirect to ftp:// might be used to access files of a FTP server which might be in a secure zone and not be reachable from the net but from the ownCloud server)

Get final redirect manually using get_headers()

Migrate to HTTPHelper class and add unit tests

Conflicts:
	apps/files/ajax/newfile.php
	lib/private/files/storage/dav.php
	lib/private/server.php
	lib/private/util.php
	lib/public/iservercontainer.php
Use non-empty defaults
Merge branch 'stable7' into backport-11211

Conflicts:
	config/config.sample.php