Skip to content

Conversation

Lctrs
Copy link
Contributor

@Lctrs Lctrs commented Jan 21, 2025

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? yes
Issues Fix #36858 Fix #49937 Fix #41843 Fix #61588
License MIT

https://www.rfc-editor.org/rfc/rfc9111.html

@carsonbot

This comment has been minimized.

@Lctrs Lctrs marked this pull request as ready for review January 21, 2025 23:54
@carsonbot carsonbot added this to the 7.3 milestone Jan 21, 2025
@stof
Copy link
Member

stof commented Jan 22, 2025

Can we bring this to CachingHttpClient (with a BC layer) instead of introducing a new class that is the good implementation of caching but with a name that is much less clear ?
Also, having the RFC id in the class name is a bad idea to me, as it would be a pain if a new RFC gets released to replace the current one (which happened multiple times for RFCs related to HTTP)

@Lctrs Lctrs force-pushed the rfc9111-http-client branch from 62db76a to 5b52dd2 Compare February 18, 2025 20:59
@Lctrs Lctrs changed the title [HttpClient] Add an RFC 9111 compliant client [HttpClient] Make CachingHttpClientCompatible with RFC 9111 Feb 18, 2025
@Lctrs Lctrs changed the title [HttpClient] Make CachingHttpClientCompatible with RFC 9111 [HttpClient] Make CachingHttpClient compatible with RFC 9111 Feb 18, 2025
@Lctrs
Copy link
Contributor Author

Lctrs commented Feb 19, 2025

UPDATE:

  • CI failure on PHP 8.5 is unrelated
  • Psalm failure seems to be a false positive to me
  • Tests pass locally on low deps, but not on github actions. I need to look at it.
  • I don't know how to please fabbot. Should I not make any change to the upgrade file ?

Otherwise, PR is ready on my side. Ready for another reviews.

@Lctrs Lctrs force-pushed the rfc9111-http-client branch 2 times, most recently from b7a0bb4 to 12bf66f Compare February 20, 2025 16:16
@Lctrs Lctrs requested a review from stof February 21, 2025 08:45
@Lctrs Lctrs force-pushed the rfc9111-http-client branch from e93f3b2 to d0be468 Compare February 22, 2025 23:19
@OskarStark OskarStark changed the title [HttpClient] Make CachingHttpClient compatible with RFC 9111 [HttpClient] Make CachingHttpClient compatible with RFC 9111 Feb 24, 2025
@Lctrs Lctrs force-pushed the rfc9111-http-client branch 3 times, most recently from b9df14d to 0405dc5 Compare February 28, 2025 10:51
@Lctrs Lctrs force-pushed the rfc9111-http-client branch from 7c66ffd to 17d0fdc Compare August 27, 2025 23:38
Copy link
Member

@stof stof left a comment

Choose a reason for hiding this comment

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

Looks good to me, but I'd like a review from @nicolas-grekas as he is the one knowing symfony/http-client best.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

I didn't get into all details but still LGTM thanks!

throw new \LogicException(\sprintf('Using "%s" requires the HttpKernel component, try running "composer require symfony/http-kernel".', __CLASS__));
}
if ($cache instanceof StoreInterface) {
trigger_deprecation('symfony/http-client', '7.3', 'Passing a "%s" as constructor\'s 2nd argument of "%s" is deprecated, "%s" expected.', StoreInterface::class, __CLASS__, TagAwareCacheInterface::class);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
trigger_deprecation('symfony/http-client', '7.3', 'Passing a "%s" as constructor\'s 2nd argument of "%s" is deprecated, "%s" expected.', StoreInterface::class, __CLASS__, TagAwareCacheInterface::class);
trigger_deprecation('symfony/http-client', '7.4', 'Passing a "%s" as constructor\'s 2nd argument of "%s" is deprecated, "%s" expected.', StoreInterface::class, __CLASS__, TagAwareCacheInterface::class);

@@ -5,6 +5,7 @@ CHANGELOG
---

* Deprecate using amphp/http-client < 5
* Add RFC 9111–based caching support to `CachingHttpClient`
Copy link
Member

Choose a reason for hiding this comment

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

let's mention the deprecation also

 * Deprecate passing an instance of `StoreInterface` as `$cache` argument to `CachingHttpClient` constructor

return new AsyncResponse($this->client, $method, $url, $options);
}

$requestHash = self::hash($method.$fullUrl.json_encode(array_intersect_key($options['normalized_headers'], self::RESPONSE_INFLUENCING_HEADERS), \JSON_THROW_ON_ERROR));
Copy link
Member

Choose a reason for hiding this comment

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

serialize instead of json_encode to work with non-utf8 chars?

@nicolas-grekas
Copy link
Member

Can you please maybe expand in the PR description? Think about a blog post we could derive from it :)

@Lctrs
Copy link
Contributor Author

Lctrs commented Sep 5, 2025

I'm currently on holiday. I'll get back to it next week. Including my thoughts on possible race conditions discussed earlier.

Can you please maybe expand in the PR description? Think about a blog post we could derive from it :)

May you be more specific ? You want me to explain the code ?

@nicolas-grekas
Copy link
Member

What we could put in the doc about it yes (thus not internal details of course)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants