Skip to content

stream_context_set_default in head() doesn't reset http method 'HEAD' #5

@bkonetzny

Description

@bkonetzny

stream_context_set_default in HttpAdapter::head() doesn't reset http method 'HEAD', once it is set. This leaves later calls to file_get_contents() without a context with this method.
In our case, this confuses other libraries whic use file_get_contents() after HttpAdapter::head() was called and we need to explicitly call stream_context_set_default(['http' => ['method' => 'GET']]) to make them work again. Not sure if thats a bug in PHP (7.0.x) or intended to work like this, the documentation on https://www.php.net/manual/en/function.stream-context-set-default.php has no info about this.

Current workaround is to set supportsHead = false as the default is then not pushed to to the configuration, but then we get the overhead of fetching all the content.

Would a PR be accepted where we enforce ['http' => ['method' => 'GET']] in the defaults when resetting the config? I'd be happy to provide a PR then.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions