flysystem-http icon indicating copy to clipboard operation
flysystem-http copied to clipboard

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

Open bkonetzny opened this issue 6 years ago • 0 comments

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.

bkonetzny avatar Jun 18 '19 10:06 bkonetzny