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

Allow Configuration Option to Disable GZip Compression #220

Closed
kzettlmeier opened this issue May 9, 2024 · 3 comments
Closed

Allow Configuration Option to Disable GZip Compression #220

kzettlmeier opened this issue May 9, 2024 · 3 comments

Comments

@kzettlmeier
Copy link

kzettlmeier commented May 9, 2024

We are currently using your library and setting the apiHost to our own proxy server to handle some updates on our end. In that proxy, we do some manipulation of the request body. Since GZip is enabled, this makes things a but more complicated on our end where we first have to decompress, then change data, and then compress again before sending the data onward. It would be nice if we could disable GZip compression in the Analytics configuration instead.

internal fun HttpURLConnection.createPostConnection(): Connection {
val outputStream: OutputStream
setRequestProperty("Content-Encoding", "gzip")
outputStream = GZIPOutputStream(this.outputStream)
return object : Connection(this, null, outputStream) {

As a note, we currently use your swift, golang, and .NET libraries with the same proxy and have for a while. Those libraries don't enable GZip compression, this is only one we have seen that does this which we found odd.

Second note, if you are willing to allow for this, I would be more than happy to contribute the change to the repository following the guidelines you have set, just didn't want to waste my time if its not something the team is interested in.

@wenxi-zeng
Copy link
Contributor

@kzettlmeier that's a good suggestion. in fact, enabling gzip should be the responsibility of RequestFactory. it is not doing this way now. we will add a fix to this

@kzettlmeier
Copy link
Author

Awesome thanks @wenxi-zeng thats great to hear!

@wenxi-zeng
Copy link
Contributor

this is fixed in 1.16.1. you can create a custom request factory and pass it to configuration to overwrite the gzip header

        object : RequestFactory() {
            override fun upload(apiHost: String): HttpURLConnection {
                val connection: HttpURLConnection = openConnection("https://$apiHost/b")
                connection.setRequestProperty("Content-Type", "text/plain")
                connection.doOutput = true
                connection.setChunkedStreamingMode(0)
                return connection
            }
        }

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