developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
#656 closed enhancement (fixed)
jIRestController must be PUT friendly
Reported by: | greut | Owned by: | laurentj |
---|---|---|---|
Priority: | low | Milestone: | Jelix 1.2 beta |
Component: | jelix:core request | Version: | 1.0.5 |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Documentation needed: | no | |
Hosting Provider: | Php version: |
Description
You cannot gets the params send with a PUT call from the jController usual $this->param("..."); without this little hack. Can you consider moving this into jController? (It's only required for PUT, yeah PHP isn't that REST friendy ;-D)
<?php class restCtrl extends jController implements jIRestController { function put(){ $_PUT = array(); parse_str(file_get_contents("php://input"), $_PUT); $this->request->params = array_merge($this->request->params, $_PUT); //... } }}}} Thanks a lot.
Attachments (2)
Change History (10)
comment:1 Changed 12 years ago by greut
- Summary changed from JIRestController must be PUT friendly to jIRestController must be PUT friendly
comment:2 Changed 12 years ago by laurentj
- Component changed from jelix:controllers to jelix:core request
- Owner set to laurentj
- Priority changed from normal to low
I've just create a first patch which is a better integration into Jelix than your's.
However, The parsing of a multipart/form-data content is not a full implementation of the specification (RFC 2388), so we have to improve it. It could be interesting to support files into multipart/form-data, so files could be handled like PHP does for POST (content saved in temporary files, and $_FILES is filled with informations of this files).
For the gold edition, perhaps we can create a function in the PHP extension of Jelix, which could call the internal API of the PHP engine, which parses multipart/form-data contents.
Another point on which I should study: should we have a specific request object to support REST or not...
comment:3 Changed 12 years ago by laurentj
- Type changed from bug to enhancement
Changed 12 years ago by greut
petit correctif, de la première version du patch (qui ne casse pas mon application existante)
comment:4 Changed 12 years ago by greut
Thanks a lot, I can clean up a little my application now.
To have it working properly, I had to adapt the fix made to jClassicRequest a little bit (attachment:656_v2.diff)
To fully supporting the RFC, it could be interesting to have proper tests for that. This is deffo something nice to have. I don't think getting $_PUT is tied to REST only and I didn't make other funky workaround to have something that work.
Cheers,
-- Yoan
PS: s/Greut/Yoan Blanc/g ;-)
comment:5 Changed 12 years ago by laurentj
- Milestone set to Jelix 1.2
comment:6 Changed 11 years ago by laurentj
- Resolution set to fixed
- Status changed from new to closed
comment:7 Changed 11 years ago by laurentj
- Documentation needed set
comment:8 Changed 11 years ago by laurentj
- Documentation needed unset
I've ended up with a more complex hack, since the REST client is using curl (from PHP) and sends a multipart/form-data within the body.
But this is so ugly that I think I'm doin' it wrong.