Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a PR to fix the issue raised in #152 which I've also encountered after applying the patch from #139 to be able to use the WorkersKV endpoints.
The fix is quite basic and there might be a better of doing this, but from what I can see whenever there's either success or error responses they are always in JSON format, except for the one random endpoint to 'Read key-value pair ' (https://api.cloudflare.com/#workers-kv-namespace-read-key-value-pair) which returns the value of the key in plain text.
So to get around that I just checked if the first character of the response is a { or not, and if it's not then skip all the json code below otherwise it fails with a 'json syntax' error since it's a plain text.
I ran all the tests and they passed, however I didn't write a new one as the change is to the Guzzle adapter which already has all the tests.
I guess I could try writing one to cover the 'plain text' response from the API.