Skip to content

Conversation

jely2002
Copy link

@jely2002 jely2002 commented Oct 3, 2025

Description

Changes the responseHasBody check, so that in case of a null or -1 for the size value we peek at the content to confirm if we have a body or not.

Motivation and context

With this change a body size of -1/null no longer evaluates to the response having a body. Meaning responses with a -1 for the size get a proper check.

Closes #110

How has this been tested?

I've added 2 tests that check if the new piece of code can detect empty/filled responses when the size is unknown.
I think this won't have many more side effects in the rest of the code.

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

Please, please, please, don't send your pull request until all of the boxes are ticked. Once your pull request is created, it will trigger a build on our continuous integration server to make sure your tests and code style pass.

  • I have read the CONTRIBUTING document.
  • My pull request addresses exactly one patch/feature.
  • I have created a branch for this patch/feature.
  • Each individual commit in the pull request is meaningful.
  • I have added tests to cover my changes.
  • If my change requires a change to the documentation, I have updated it accordingly.

If you're unsure about any of these, don't hesitate to ask. We're here to help!

@jely2002 jely2002 requested a review from JaZo October 3, 2025 09:58
@jely2002 jely2002 self-assigned this Oct 3, 2025
@jely2002 jely2002 added the bug Something isn't working label Oct 3, 2025
@jely2002 jely2002 changed the title fix: change bool cast to empty check when checking for a response body fix: improve responseHasBody check for responses with an unknown size Oct 3, 2025
return true;
}

$contents = (string) $body;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we read just a few bytes instead of the entire stream?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect parsing of 204 response
2 participants