Skip to content

Implement tests for range and partial content responses - #619

Merged
alamb merged 3 commits into
apache:mainfrom
vitoordaz:get-tests
Feb 3, 2026
Merged

Implement tests for range and partial content responses#619
alamb merged 3 commits into
apache:mainfrom
vitoordaz:get-tests

Conversation

@vitoordaz

@vitoordaz vitoordaz commented Jan 23, 2026

Copy link
Copy Markdown
Contributor

Added tests for handling partial content responses and retries for incomplete response bodies.

Which issue does this PR close?

I didn't file an issue, because this PR only adds unit tests.

Rationale for this change

This improves code coverage and effectively documents how client behaves in edge case situation.

What changes are included in this PR?

Only unit tests for GetClient

Are there any user-facing changes?

No

@vitoordaz

vitoordaz commented Jan 26, 2026

Copy link
Copy Markdown
Contributor Author

@alamb how do you feel about this PR?

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @vitoordaz -- I took a quick look and it seems like a nice addition to me. I have one test question, otherwise I think this is ready to go

Comment thread src/client/get.rs
assert_eq!(b.as_ref(), b"ello");

// NOTE: if debug_assertions is true, hyper panics with response content length header
// value does not match the length of response body.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this mean hyper would panic in a real world case? If so, is there a ticket tracking it?

Or does this mean that this particular response is not valid (and thus we shouldn't be testing it)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hyper panics in test environment which usually have debug_assertions = true. In prod debug_assertions = false and hyper returns regular response.

I'm wondering if we can update CI to run all tests with debug_assertions = false as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we can update CI to run all tests with debug_assertions = false as well?

We could add a new test run with that enabled (or perhaps we could run the tests in --release mode)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, I think that this will work. I was using this command to run this test

RUSTFLAGS="-C debug-assertions=false" RUST_BACKTRACE=full cargo test --features http client::get::http_tests::test_stream_retry

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps you can do so as a follow on PR

@alamb

alamb commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

I think if you can merge up from main the CI tests would also pass cleanly

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @vitoordaz

@alamb

alamb commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

(please just merge up from main so we can get a clean CI run)

Added tests for handling partial content responses and retries for incomplete response bodies.
Removed unnecessary empty lines in the get.rs file.
@alamb
alamb merged commit 19264b8 into apache:main Feb 3, 2026
8 checks passed
@alamb

alamb commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Thanks @vitoordaz

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