Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Honor psr7 protocol version#62048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@ajgarlag
Copy link
Contributor

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
Issues
LicenseMIT

When a PSR-7 request is sent usingPsr18Client, the PSR-7 request protocol version is only converted to the underlyinghttp_version option when is set to1.0, so we cannot control that option for1.1 or2.0.

I have a project where I need to dynamically force the use of protocol version1.1 but the final request is always sent using version2.0.

@carsonbotcarsonbot added this to the6.4 milestoneOct 13, 2025
@ajgarlagajgarlag changed the title[Http-Client] Honor psr7 protocol version[HttpClient] Honor psr7 protocol versionOct 13, 2025
@nicolas-grekas
Copy link
Member

The current behavior allows defaulting to 2.0 when ppl didn't specify any protocol. This happens most of the time.
Merging as is would be a regression for many as it would mean switching to HTTP/1.1 when 2.0 is used today.
That's a drawback of the PSR-7 interface; not being able to tell if ppl really did intent to use that version of HTTP, or if that's just some default.

An idea might be to find a way to tell the difference when our owncreateRequest() is used.

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedOct 13, 2025
edited
Loading

Another idea: add a dedicated option to the client (usable by callingwithOptions()).

Side note: a similar patch will be required onHttplugClient.

@carsonbotcarsonbot changed the title[HttpClient] Honor psr7 protocol version Honor psr7 protocol versionOct 13, 2025
@ajgarlag
Copy link
ContributorAuthor

The current behavior allows defaulting to 2.0 when ppl didn't specify any protocol. This happens most of the time. Merging as is would be a regression for many as it would mean switching to HTTP/1.1 when 2.0 is used today. That's a drawback of the PSR-7 interface; not being able to tell if ppl really did intent to use that version of HTTP, or if that's just some default.

The PSR-7 interface defines agetProtocolVersion method that always returns a string, meaning that the protocol version is set for every request. While most PSR-7 implementations use1.1 by default in the request constructor, the constructor itself is not part of the PSR-7 specification.

The currentPsr18Client implementation assumes that if the protocol version is set to1.1, this is because the caller has forgotten to set it to2.0. However, in my project, this is a deliberate decision.

Any caller code can change the protocol version set in the PSR-7, no matter which PSR-7 implementation is being used, so I see no need to create a dedicated option in the client.

What do you think about proposing this as a feature retargeting the PR to Symfony 8?

@nicolas-grekas
Copy link
Member

I think I already shared my vision, and its rationale :)
So no: doing this change on 8.0 will lead to the same concern - a regression for most.

@nicolas-grekas
Copy link
Member

most PSR-7 implementations use 1.1 by default in the request constructor, the constructor itself is not part of the PSR-7 specification.

The request factory is, so thereis a standardized way to create PSR-7 objects. And of course nobody calls>withProtocolVersion() - because why hardcode for a specific version anyway.

I suggested two alternatives:

  • an option at the client level
  • tracking calls to>withProtocolVersion(), by returning a decorated request when calling$client->createRequest()

Possibly implementing both proposals.

@ajgarlag
Copy link
ContributorAuthor

Closing in favor of#62059

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

3 participants

@ajgarlag@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp