-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Labels
FeatureHttpFoundationRFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)
Description
Q | A |
---|---|
Bug report? | no |
Feature request? | yes |
BC Break report? | no |
RFC? | yes |
Symfony version | 3.x |
In Python, the framework Flask has a method on its AcceptHeaders
equivalent called best_match
which basically compares the Accept
header with your list of available content-types and returns the best match.
I found myself implementing this manually in an abstract controller class:
foreach ($request->getAcceptableContentTypes() as $type) {
if ($type == 'application/json') { return $type; }
if ($type == 'text/plain') { return $type; }
if ($type == 'text/html') { return $type; }
}
return 'text/plain';
Is this something that could be added to the AcceptHeaders
class?
PS: I wasn't able to find any info on what RFC yes/no entails so I might have put the wrong thing there.
(edit by @lyrixx: Yes, it's a RFC, I fixed the PR description. Thanks)
Metadata
Metadata
Assignees
Labels
FeatureHttpFoundationRFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)