Skip to content

Can't easily get ALL headers for a storage object #285

Description

@dsnopek

I needed to get a header that isn't one of the built-in ones (ETag, Content-Length, Last-Modified, Content-Type) or metadata (ie. starting with 'X-Object-Meta-'), and there wasn't an easy way to do it.

(Specifically, I needed to get the 'X-Object-Manifest' header, because $object->delete() on a large object won't actually delete the segments that make it up, only the manifest! See #286)

I had do something like this:

class MyClass {
  protected function apiHeadObject() {
    $params = new Params();
    return [
        'method' => 'HEAD',
        'path'   => '{containerName}/{+name}',
        'params' => [
            'containerName' => $params->containerName(),
            'name'          => $params->objectName(),
        ],
    ];
  }

  public function getHeaders($container, $object_name) {
    $object = $this->service
      ->getContainer($container)
      ->getObject($object_name);

    /** @var \Psr\Http\Message\ResponseInterface $response */
    $response = $object->executeWithState($this->apiHeadObject());
    return $response->getHeaders();
  }
}

Given that there's lots of extensions to OpenStack which can be optionally enabled, including custom ones that a hosting provider may have created, it'd be nice to just have a way to arbitrarily get headers from an object.

Perhaps anything starting with 'X-' (other than metadata) could be captured in an additional array?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions