Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to customize curlopts_encoding - PHP failing when Jira responds with Brotli encoding #79

Open
rmerrellgr opened this issue Apr 8, 2024 · 1 comment

Comments

@rmerrellgr
Copy link

rmerrellgr commented Apr 8, 2024

We're not sure when this started or the EXACT cause of the issue, but we have plenty of smoking guns and a bandaid solution. To be clear, this isn't a php-JiraCloud-RESTAPI bug, but it requires a code change for the solution.

We (Mac OS 14.1.1 - M2 Chip - PHP installed with Homebrew) recently started experiencing issues with a deployment script that uses php-JiraCloud-RESTAPI. The script uses the IssueService get() function to retrieve Issue data. One day, after a forced brew update (not sure what exactly updated), it stopped working. We found that the response variable we would store the retrieved data was no longer including the json object, but rather was a "boolean" returning false. Further debugging showed that cURL was failing with Error "23" but a blank Error message. Looking up that error in cURL's docs gives "Failure writing output to destination". If I set CURLOPT_RETURNTRANSFER to "false", it would print the JSON to screen as expected no problem (though still flagging error 23). But with RETURNTRANSFER=true and attempting to set the response to a variable was failing. After lots of troubleshooting, I found that If I modify JiraClient.php on the line curl_setopt($ch, CURLOPT_ENCODING, ''); and set it to "gzip", it fixes the issue. But if we leave it blank, or even set it to "br" AND when we observe that Jira responds using Brotli, then our issue occurs and the request fails.

This issue is present for all of our Mac users in the office, but I haven't seen any other talk around the web about it. It's not limited to this application, it's reproducible with a very simple script using curl to retrieve an Issue from Jira using both v2 and v3 endpoints, having CURLOPT_ENCODING blank. (UPDATE: It seems to be limited to the Homebrew PHP, as it's working fine using the official php 8.1 and 8.2 docker containers.)

The solution needed is the ability to set a configuration option like curlOptEncoding where we can set it to "gzip". I could try doing a PR, but I don't really know what I'm doing. I was able to get it working for myself, but I'm not sure if the way I did it is the proper way. And I wouldn't even begin to know how to write a test.

@lesstif
Copy link
Owner

lesstif commented Apr 22, 2024

hi @rmerrellgr thank you for your suggestion. unfortunately, I didn't meet a similar situation.
however if you can make a PR, I'll merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants