Skip to content

[Http Foundation] lazy headers initialization #10077

@aeryaguzov

Description

@aeryaguzov

As I see, request headers are retrieved from the server params (ServerBag), so they can be lazy initialized on the first use. This can be a perfomance improvement for all requests which does not operate with request headers (almost all?). Moreover, some use-cases of headers can be simply replaced with server params use-cases.

So I think there is a great opportunity to improve component perfomance, but "headers" are public property of Request class, so in order to use this improvement we must set it to protected and provide a getter with lazy initialization(or provide magic __get() with "headers" property handling - bad way, IMHO). This is BC breaking improvement.

What do you think about that?
If you agree with me, I can provide a PR for this improvement.

Also, I can admit that headers are poorly architectured today(ex. handling cache-control header in HeadersBag). I think we should have header classes in which we can handle particular header use-cases (like zf2 headers) and if we do so, this improvement will make more sense.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions