Closed kzettlmeier closed 5 months ago
@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
Awesome thanks @wenxi-zeng thats great to hear!
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
}
}
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 theAnalytics
configuration instead.https://github.com/segmentio/analytics-kotlin/blob/bfd04185a3b38f1336545acb197d58a34bc38aca/core/src/main/java/com/segment/analytics/kotlin/core/HTTPClient.kt#L90-L94
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.