Closed boesing closed 11 months ago
One important consideration: PSR-7 packages are about abstracting HTTP messaging, so that needs to be considered upfront.
I'm fine with the proposal, just throwing in this data point.
My takes:
UriInterface
implementations, they are deviating.After some more thoughts (including the knowledge I've gathered from Marcos and Matthews comments), I decided to tackle the underlying issue in mezzio-cors
.
To summarize:
RequestInterface#withScheme
may throw InvalidArgumentException
for unsupported schemesThanks for the feedback here and in Slack.
RFC
Goal
Remove the scheme filtering which prevents creating non-HTTP URIs.
Background
Diactoros is providing a PSR-7
UriInterface
implementation butUri
is not tied toHTTP
only. Inmezzio/mezzio-cors
, we do make use of theUriInterface
forOrigin
.We do use the CORS implementation in our project which seems to be requested from within whatever chrome extension. When that chrome extension does execute requests, we receive the following Origin:
When parsing that origin header and after passing to
UriFactoryInterface#createUri
, an exception is thrown:Considerations
I do not really see a huge benefit in having this kind of restriction unless the class is named
HttpUri
. I am aware that extending theUri
might be a solution (as I could extendallowedSchemes
), but since we do addfinal
to a bunch of components lately, at some point, theUri
of diactoros will receive that as well. Due to the fact that the CORS component does not use diactoros directly, I am unsure if that issue should be handled by upstream users. However, I've checkednyholm/psr7
andguzzlehttp/psr7
and both are "fine" with havingchrome-extension
(or non-HTTP related schemes) in place. For the sake of interoperability, I'd love to get rid of throwing exceptions when Uris are created with non-HTTP schemes.Proposal(s)
Just remove the
Uri#filterScheme
logic where we throw an exception when the scheme is not part of theallowedSchemes
map. We should just verify that the scheme is valid as per RFC definition.Appendix