Skip to content

Commit

Permalink
Work on #464.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjordan committed Apr 16, 2018
1 parent 15722f8 commit 87dcc7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/fetchermanipulators/OaipmhIslandoraByMimetype.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public function manipulate($records)
public function getMimeType($record_key)
{
// Get the OAI record from the temp directory.
$raw_metadata_path = $this->settings['FETCHER']['temp_directory'] . DIRECTORY_SEPARATOR . $record_key . '.metadata';
$raw_metadata_path = $this->settings['FETCHER']['temp_directory'] .
DIRECTORY_SEPARATOR . $record_key . '.metadata';
$dom = new \DOMDocument;
$xml = file_get_contents($raw_metadata_path);
$dom->loadXML($xml);
Expand Down Expand Up @@ -119,9 +120,9 @@ public function getMimeType($record_key)
// HEAD is more efficient than the default GET.
stream_context_set_default(array('http' => array('method' => 'HEAD')));
$headers = get_headers($ds_url, 1);
if ($dsid == $this->dsid && $headers[0] == 'HTTP/1.1 200 OK' && isset($headers['Content-Type'])) {
if ($dsid == $this->dsid && preg_match('#200\sOK#', $headers[0]) && isset($headers['Content-Type'])) {
return $headers['Content-Type'];
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/filegetters/OaipmhIslandoraObj.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function getFilePath($record_key)
// HEAD is probably more efficient than the default GET.
stream_context_set_default(array('http' => array('method' => 'HEAD')));
$headers = get_headers($ds_url, 1);
if ($headers[0] == 'HTTP/1.1 200 OK') {
if (preg_match('#200\sOK#', $headers[0])) {
return $ds_url;
}
}
Expand Down

0 comments on commit 87dcc7b

Please sign in to comment.