Skip to content

[RFC] Mutable HTTP request/response #30

@chriskapp

Description

@chriskapp

there were many discussions about the immutable/mutable design of PSR-7 on the PGP-FIG mailing list. Eventually the objects are now immutable which was decided mostly by the designers of the PSR. With this issue I want to see how the community feels about this decision.

The bigest problem of immutability is that it is not easy possible to convert an application which is using a mutable response to an immutable implementation. Since the most popular HTTP implementation (Symfony/HttpFoundation) is mutable all applications which are using these objects probably rely on the mutability. I.e. with mutability it is easy to pass an HTTP response to a middleware or event listener which modifies the response. With immutability you also have to return the changed instance back to the application which is not always possible or requires a major change of the application design.

If there are also other people who would like to see such a mutable version I would post a first draft to this issue. Essentially this would mean to replace all with* methods with set* methods which are working on the object instead of returning a new object. If all people are happy with the current PSR-7 design it is also ok but I want to hear the feedback ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions