Skip to content

Commit ef2f2f8

Browse files
authored
Merge pull request #139 from RADAR-base/fix-get-users
Fix get users
2 parents 8b6360a + 78c20fe commit ef2f2f8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kafka-connect-fitbit-source/src/main/java/org/radarbase/connect/rest/fitbit/user/ServiceUserRepository.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,10 @@ class ServiceUserRepository : UserRepository {
240240
): T = withContext(Dispatchers.IO) {
241241
val response = client.request(builder)
242242
val contentLength = response.contentLength()
243-
val hasBody = contentLength != null && contentLength > 0
243+
// if Transfer-Encoding: chunked, then the request has data but contentLength will be null.
244+
val transferEncoding = response.headers["Transfer-Encoding"]
245+
val hasBody = (contentLength != null && contentLength > 0) ||
246+
(transferEncoding != null && transferEncoding.contains("chunked"))
244247
if (response.status == HttpStatusCode.NotFound) {
245248
throw NoSuchElementException("URL " + response.request.url + " does not exist")
246249
} else if (!response.status.isSuccess() || !hasBody) {

0 commit comments

Comments
 (0)