Skip to content

Conversation

@rajanyadav0307
Copy link
Contributor

Issue #, if available:

Issue-3364: Fix Proposal


Description of changes:

This PR fixes an issue in CurlHttpClient::WriteData where querying the output position of the response body stream could cause the HTTP transfer to abort when the stream does not support positioning (e.g., boost::iostreams::filtering_stream with compression/decompression filters).

Problem

The existing implementation attempted to query the current write position of the response body stream using positioning APIs (tellp() / seek operations) for diagnostic purposes. For non-seekable output streams, this operation may fail and set the stream into a bad state, which caused the SDK to treat the write as a fatal error and abort the transfer, even though the actual write() operation itself was valid and succeeded.

This behavior is expected for certain stream types and should not be treated as a write failure.

Fix

  • Avoid treating unsupported output position queries as fatal errors.
  • Introduce a best-effort, non-intrusive position probe that detects whether the stream supports positioning without modifying stream state.
  • Preserve existing behavior for seekable streams while allowing non-seekable streams to function correctly.
  • Continue using the existing byte counter (m_numBytesResponseReceived) for accurate response size tracking.

This change improves compatibility with clients that use non-seekable or filtering output streams without altering public APIs or behavior for existing seekable stream use cases.


Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR.
    (Added a regression test guarded by ENABLE_HTTP_CLIENT_TESTING that validates non-seekable response streams do not abort transfers. This follows the existing CurlHttpClient test pattern and requires the local dummy HTTP server for execution.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Platforms verified:

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Sign-off:
Rajan Y. (rajanyadav0307@gmail.com)

Sign-off: Rajan Y.(rajanyadav0307@gmail.com)
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.

1 participant