Skip to content

Simplify .content #963

@mhils

Description

@mhils

Our HTTPRequest/HTTPResponse's .content attribute can currently be either

  • None, if we have not read the body yet (e.g. in the reponseheaders hook)
  • CONTENT_MISSING=0, if we deliberately deleted the body
  • b"", if we read an (empty) body.
  • b"some-content", if we actually read some content.

While the first three values intuitively evaluate to False, I feel the bytes/int/None heterogenity a bit confusing. I'd like to combine the first two cases, so that the type of this attribute can accurately be described as Optional[bytes]. This would fix #692 and make the code IMO easier to understand. We could also first deprecate CONTENT_MISSING gradually by setting it to None, and then remove it later on. @cortesi, would you be okay with this approach?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions