1
0
Fork 0

Clean ups, refs #5485

pull/5490/head
Jordi Boggiano 2016-07-02 17:49:46 +01:00
parent 8ffe224c0d
commit 87fbf4a6cd
1 changed files with 5 additions and 23 deletions

View File

@ -175,24 +175,6 @@ class RemoteFilesystem
return $value; return $value;
} }
/**
* @param array $headers array of returned headers
* @return string|null
*/
public function findContentType(array $headers)
{
$value = null;
foreach ($headers as $header) {
if (preg_match('/^Content-type:\s*([^;]+)/i', $header, $match)) {
// In case of redirects, http_response_headers contains the headers of all responses
// so we can not return directly and need to keep iterating
$value = $match[1];
}
}
return $value;
}
/** /**
* Get file content or copy action. * Get file content or copy action.
* *
@ -355,14 +337,14 @@ class RemoteFilesystem
$contentType = null; $contentType = null;
if (!empty($http_response_header[0])) { if (!empty($http_response_header[0])) {
$statusCode = $this->findStatusCode($http_response_header); $statusCode = $this->findStatusCode($http_response_header);
$contentType = $this->findContentType($http_response_header); $contentType = $this->findHeaderValue($http_response_header, 'content-type');
} }
if ($originUrl === 'bitbucket.org' && // check for bitbucket login page asking to authenticate
preg_match('/\.zip$/', $fileUrl) && if ($originUrl === 'bitbucket.org'
$contentType === 'text/html' && substr($fileUrl, -4) === '.zip'
&& preg_match('{^text/html\b}i', $contentType)
) { ) {
// The received content is a login page asking to authenticate
$result = false; $result = false;
if ($this->retryAuthFailure) { if ($this->retryAuthFailure) {
$this->promptAuthAndRetry(401); $this->promptAuthAndRetry(401);