1
0
Fork 0

Fix IHTTPResult::getHeader()

- Now returns a string array, like expected
- Fix usages
- Fix dataset
This commit is contained in:
Philipp Holzer 2020-10-09 22:28:41 +02:00
commit 80bd0a4d5a
No known key found for this signature in database
GPG key ID: 9A28B7D4FF5667BD
11 changed files with 68 additions and 59 deletions

View file

@ -245,7 +245,7 @@ class CurlResult implements IHTTPResult
public function getHeader($header)
{
if (empty($header)) {
return '';
return [];
}
$header = strtolower(trim($header));
@ -256,7 +256,7 @@ class CurlResult implements IHTTPResult
return $headers[$header];
}
return '';
return [];
}
/** {@inheritDoc} */
@ -289,7 +289,11 @@ class CurlResult implements IHTTPResult
$parts = explode(':', $line);
$headerfield = strtolower(trim(array_shift($parts)));
$headerdata = trim(implode(':', $parts));
$this->header_fields[$headerfield] = $headerdata;
if (empty($this->header_fields[$headerfield])) {
$this->header_fields[$headerfield] = [$headerdata];
} elseif (!in_array($headerdata, $this->header_fields[$headerfield])) {
$this->header_fields[$headerfield][] = $headerdata;
}
}
return $this->header_fields;

View file

@ -19,7 +19,7 @@ interface IHTTPResult
/**
* Returns the Content Type
*
* @return string the Content Type
* @return string[] the Content Types
*/
public function getContentType();
@ -29,7 +29,7 @@ interface IHTTPResult
*
* @param string $header optional header field. Return all fields if empty
*
* @return string the headers or the specified content of the header variable
* @return string[] the headers or the specified content of the header variable
*/
public function getHeader($header);

View file

@ -429,7 +429,7 @@ class Probe
}
// If it isn't a HTML file then exit
if (($curlResult->getContentType() != '') && !strstr(strtolower($curlResult->getContentType()), 'html')) {
if (!in_array('html', $curlResult->getContentType())) {
return false;
}