csarrazi / guzzle-cache-middleware

A Guzzle Cache middleware
54 stars 10 forks source link

Special characters make the SubfolderNamingStrategy fail #5

Open Tobion opened 6 years ago

Tobion commented 6 years ago

When there are special characters in the URI path that are not allowed by the filesystem (like : on Windows), the MockStorageAdapter using SubfolderNamingStrategy fails with

Symfony\Component\Filesystem\Exception\IOException: Failed to create "/vagrant/tests/fixtures/guzzle/.../transform;key=rest:api": mkdir(): Input/output error.

And unfortunately one cannot reconfigure the adapters, making the caching / mocking unusable.

csarrazi commented 6 years ago

Good point. I think we should simply ignore reserved characters for all operating systems, when fetching the path information from the URI.

Tobion commented 4 years ago

Btw, the https://github.com/csarrazi/guzzle-cache-middleware/blob/master/src/Adapter/MockStorageAdapter.php does not seem necessary. You could use the https://github.com/csarrazi/guzzle-cache-middleware/blob/master/src/Adapter/PsrAdapter.php also for the mock storage. In the https://github.com/csarrazi/CsaGuzzleBundle you could use the symfony filesystem cache adapter without ttl and the IdentityMarshaller (or a custom one for responses).

Tobion commented 4 years ago

This way the library also wouldn't need to worry about such things like invalid chars. But the cache key would usually not translate to the filename as the key is likely hashed.