Bug Report #4315
Internal sub-request not receiving correct accept type
| Status: | Closed | Start date: | 10/27/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | Core | |||
| Target version: | v3.3.0 | |||
| Resolution: | wontfix | Points: | 1 |
Description
When making an internal sub-request, if you set the accept-type for the sub-request, for example to application/json, when in the sub-request, if you output $this->request->accept_type(), it doesn't have the desired type, but rather has inherited from the parent request.
$place = Request::factory(Route::get('api')->uri(array('controller' => 'location', 'action' => 'google-place-details-api')))
->query(array('reference' => $reference))
->headers('Accept-Type', 'application/json')
->execute();
In the sub-request, I'm checking the accept type to determine what output to return, but Request::accept_type() pulls from the global $_SERVER variable once, and stores it statically. But this doesn't make sense for sub-requests, which should read from the header object in the request if set?
https://github.com/kohana/core/blob/3.2/master/classes/kohana/request.php#L457
Related issues
Associated revisions
Deprecated Request::parse_accept(), refs #4315
Deprecated Request methods: accept_lang(), accept_encoding(), accept_type(), refs #4315
Follow up to f3425119c7b5cb1a7e49b92730d1c10c0415b155, reference HTTP_Header methods where acceptable, refs #4315
History
Updated by Sam de Freyssinet 7 months ago
- Status changed from New to Feedback
- Assignee set to Sam de Freyssinet
The Request::accept_type() method is a hang-over from the 3.0 release. It shouldn't be used for anything other than the initial request, and you may argue that it shouldn't be used at all. Request::headers('accept-type') is how you would retrieve the accept type of any request object, including sub requests. I am going to deprecate the Request::accept_type() class method in 3.3.
Updated by Woody Gilk 4 months ago
- Assignee changed from Sam de Freyssinet to Woody Gilk
- Target version set to v3.3.0
Committed a deprecation, as per Sam. Maybe we should do something similar to #3396 and make `Request::_parse_accept` something more agnostic?
Updated by Sam de Freyssinet 4 months ago
The HTTP_Header class handles all of this encapsulated. Also helps if you use the correct http headers!
Updated by Kiall Mac Innes 3 months ago
Sam / Woody - Is this ticket now closeable?
Updated by Woody Gilk 3 months ago
- Status changed from Feedback to Closed
- Resolution set to wontfix
I'm going to mark this as "wontfix" since the underlying issue is not really solved, but rather the methods described by the OP are deprecated.