Skip to content

Commit

Permalink
chop off charset from mimetype for external content header (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
whikloj authored Oct 22, 2021
1 parent ee9ea25 commit 09a62a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Milliner/src/Service/MillinerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function saveNode(
$fedora_url = "$islandora_fedora_endpoint/$path";

$response = $this->fedora->getResourceHeaders($fedora_url);
if ($response->getStatusCode() == "404") {
if ($response->getStatusCode() == 404) {
$this->log->debug("GOT A 404");
return $this->createNode(
$jsonld_url,
Expand Down Expand Up @@ -324,7 +324,7 @@ function (array $elem) use ($subject_url) {
// Put in an fedora url for the resource.
$resource[0]['@id'] = $fedora_url;


$this->log->debug("AFTER: " . json_encode($resource));
return $resource;
}
Expand Down Expand Up @@ -481,6 +481,9 @@ public function saveExternal(
);
}
$mimetype = $drupal_response->getHeader('Content-Type')[0];
if (preg_match("/^([^;]+);/", $mimetype, $matches)) {
$mimetype = $matches[1];
}

// Save it in Fedora as external content.
$external_rel = "http://fedora.info/definitions/fcrepo#ExternalContent";
Expand Down Expand Up @@ -556,6 +559,7 @@ public function createMediaVersion(
$urls = $this->getMediaUrls($source_field, $json_url, $islandora_fedora_endpoint, $token);
$fedora_url = $urls['fedora'];

$headers = empty($token) ? [] : ['Authorization' => $token];
$date = new DateTime();
$timestamp = $date->format("D, d M Y H:i:s O");
// create version in Fedora.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ protected function setUp(): void
* @covers ::saveNode
* @covers ::saveMedia
* @covers ::deleteNode
* @covers ::createVersion
* @covers ::createNodeVersion
* @covers ::createMediaVersion
*/
public function testMethodsReturnMillinerErrors()
{
Expand Down

0 comments on commit 09a62a4

Please sign in to comment.