Skip to content

Conversation

@osipxd
Copy link
Member

@osipxd osipxd commented Nov 14, 2025

Subsystem
ktor-client-darwin

Motivation
KTOR-9095 Darwin: HttpResponse.version always returns HTTP_1_1

Solution
Use URLSession:task:didFinishCollectingMetrics: to save transaction metrics and get protocol version from it later.

@osipxd osipxd self-assigned this Nov 14, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch osipxd/darwin-protocol

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@osipxd osipxd marked this pull request as draft November 14, 2025 18:12
if (!response.isCompleted) {
val result = dataTask.response as NSHTTPURLResponse
response.complete(result.toResponseData(requestData))
}
Copy link
Member Author

@osipxd osipxd Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually wrong. Events are called in the following order:
:didReceiveData:didFinishCollectingMetrics:didCompleteWithError

:didFinishCollectingMetrics is the place where we get the protocol version. So I thought we can complete response only from :didCompleteWithError. The problem is that this event is not called until we've completely read the body. And it is a problem for streaming responses. That's why testDownloadStreamResponseWithCancel hangs.

I'll try to find a different solution.

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

Successfully merging this pull request may close these issues.

2 participants