[Ktor + gradle plugin] 5.5.0 to 6.2.5 regression around Content-Length & Transfer-Encoding
See original GitHub issueLibrary Version 6.2.5
Describe the bug This is likely not an expedia graphql bug, but it seems prudent to start here in case others run into this, or perhaps the maintainers here have more experience and can think of an elegant fix.
The short version is: version 5.x uses Ktor in a way where the Content-Length header is present when running the :graphqlIntrospectSchema
task. Versions 6.x result in NO Content-Length header. From what I can see, the Ktor Apache engine + Jackson Ktor plugin never resolve a Content-Length, so the engine defaults to Transfer-Encoding: Chunked
While most request handlers probably don’t have issues with chunked encoding, we are using this library in a context where we have a 3rd party vendor whose GraphQL server does NOT handle chunked encoding, so this regression is causing us heartburn as we need to upgrade this library to be in lock-step other dependency upgrades (kotlin 1.7, spring, etc), and not be left behind.
We can work around this with static schema files we fetch from 5.x (the /sdl endpoint isn’t supported here, so we must use introspection) or other hacks, but it’s not ideal.
To Reproduce Steps to reproduce the behavior. Please provide:
- Schema Configuration
This is happening in a very vanilla usage context, with a very simple graphql config like:
graphql {
client {
endpoint = "http://$host/graphql"
packageName = "com.testingmyissue.graphql.generated"
queryFileDirectory = "${project.projectDir}/src/main/resources/gql"
}
}
- Kotlin code used to generate the schema
Compare the request headers from a :graphqlIntrospectSchema
request in version 5.5.0 to 6.2.5 (or probably any other minor versions).
Expected behavior
The above configs are left totally alone (but with a valid remote host, of course), and you can see the regression in this comparison, having changed only the gradle plugin version from 5.5.0 to 6.2.5:
Example 5.5.0 request headers:
POST /graphql HTTP/1.1
Accept: application/json
Accept-Charset: UTF-8
User-Agent: Ktor client
Content-Length: 1761
Content-Type: application/json
Host: [[omitted]]
Connection: Keep-Alive
Example 6.2.5 request headers:
POST /graphql HTTP/1.1
Accept: application/json
Accept-Charset: UTF-8
User-Agent: Ktor client
Transfer-Encoding: chunked
Content-Type: application/json
Host: [[omitted]
Connection: Keep-Alive
Issue Analytics
- State:
- Created a year ago
- Comments:10 (2 by maintainers)
Top GitHub Comments
Hello 👋 This is due to the change in behavior in Ktor v2.0. I opened up YouTrack KTOR-4904 issue to track it.
@maxpiepenbrink I don’t think it will work with 6.x release (we are using Kotlin 1.6 whereas Ktor is based on Kotlin 1.7 since v
2.1.0
).