aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-hreq.c
AgeCommit message (Collapse)AuthorFilesLines
2018-07-24json-c: Remove escaping of slashsJosé Bollo1-2/+5
By default json-c escapes the slashes. This is almost ugly and unuseful. But the resolution (with JSON_C_TO_STRING_NOSLASHESCAPE) was introduced lately by json-c. Integrate it as much as possible. Change-Id: Ia9c4bee78dc11df1ee9640cb04311991bd860e43 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-07-13afb-supervision: Remove dependency to externalJosé Bollo1-2/+2
Also some cleaning in use of extern to allow accurate grep. Removing extern is better for linking and for structuration. Change-Id: I8121c4b9b34fa2737bffd2ecbe170d04d1d60ad1 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-06-18afb-hsrv: Add processing of type application/jsonjobol1-0/+3
Makes the data posted as application/json directly available through json. The previous processing made content transmitted with the content-type application/json available as a string in the field of name "" of the returned json object. Change-Id: I11615b9b147ee4daa1b1358c2bd36fd839d8a7a9 Signed-off-by: jobol <jose.bollo@iot.bzh>
2018-06-15api-v3: First draftJosé Bollo1-26/+17
This commit introduces the bindings v3 API for bindings. The documentation has still to be improved and will come very soon. Change-Id: I8f9007370e29f671fdfd1da87fff7372a17db7af Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-02-27Update date of copyright noticesJosé Bollo1-1/+1
Change-Id: If9d7e7728df086fbb7214f1de5cbec35cd2f1d9b Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-01-18afb-hreq: Dichotomic mimetype searchJosé Bollo1-7/+11
Change-Id: I6d906c31cdcf07c5404f1eb81cd44683976465f7 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-01-18afb-hreq: Sort mimetypesJosé Bollo1-9/+9
Change-Id: I45ae5a702b83dabe081b625b4bcaf5de33ffa1e6 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2018-01-18afb-hreq: Add json to known mimetypesLoïc Collignon1-0/+1
Change-Id: Ic11ebf7e569160dd25e66a1273904dfcd82bdeb8 Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
2017-12-18afb-hreq: Add predefined mime-typesJosé Bollo1-7/+18
Add mimetypes for common extensions for conformance to https://www.w3.org/TR/widgets/#rule-for-identifying-the-media-type-of-a-file Change-Id: I3ae51afbbc2916b7237e4fa546392ec7ec5ea42a Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-10-09Provide API and VERB name of requestsJosé Bollo1-5/+5
Change-Id: I9a86c6314f871334231e50f9cea60b54aed434b9 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-10-09Introduce afb_requestJosé Bollo1-1/+0
This prepares the new api with pointers. Change-Id: I4eb299551145226e428934b6835a1a7810ae6439 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-10-09afb-xreq: hide internal addref/unref to xreqsJosé Bollo1-3/+3
Change-Id: Ie175ec1e508c7bd3bcdc25d7e0b26e7a9da3fafb Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-09-11afb-hreq: Fix a leak on websocket upgradeJosé Bollo1-0/+2
A 'no-reply' answer was created but not emitted nor freed when http connection was upgraded to websocket. Merging replied and xreq.replied was a possible solution but I wanted not change much things. Change-Id: I86c6c7ee52f69d50732e50fa6594f1d22d77ddfd Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-06-02Provide efficient store/unstore for afb_reqJosé Bollo1-1/+1
Change-Id: I231e2506f58227fb8d192df042539b1551a765c5 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-05-29Relax authorisation checlk for selfJosé Bollo1-1/+0
Change-Id: I115bbebb2f51be92578d1cc6b2fb5ae89813b630 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-05-29Add 'afb_service_call_sync' functionJosé Bollo1-1/+0
This new function allows to call features for the services synchronously. Also refactoring how are handled arguments to calls. The call to 'json_object_put' is now always done by the binder. Change-Id: I910517da75b179aeafc824da4ce29bc299711990 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-05-05Add default cred to HTTP linkJosé Bollo1-0/+3
Change-Id: Ibb73cebc99094b33b61820482327296049c2026a Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-13Introduce apiset for grouping apisJosé Bollo1-4/+7
This will be used at the end for debugging facilities. Change-Id: I75e3345667e1f58143c77a885e166375680ca194 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-12Optimisation of xreqJosé Bollo1-19/+21
Reduce the count of memory read Change-Id: Ie4dfa4bd30d6485be91961196294c43ffbd3b2a9 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-31Use xreq for websocketsJosé Bollo1-4/+2
Change-Id: Ia489f863e8be3384fbe8a240f6010f7d5916b72a Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-31Factorize common code for handling requestsJosé Bollo1-65/+46
The common code for session handling is shared using struct afb_xreq. At the moment only hreq leverages the new feature. The objective is double: make the work of writing new internal requests more easy and prepare to check permissions. Change-Id: If3ca311d68c2d8c427d1125f31a2704b150c2c94 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-27Simplify functions for callsJosé Bollo1-0/+16
For historical reasons, the call to apis was passing the length of the api and the length of the verb. The reason was to avoid a copy of strings. But the copy occured only for HTTP requests. Having this implementation is of small interest and compromise future changes. This patch simplify things. Change-Id: I8157724c6c721b6797cd0eab52b07e1b8d6eb5f8 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-06Add comments about always setting INFER_EXTENSION.Sebastien Douheret1-0/+6
INFER_EXTENSION must always be set in order to provide right mimetypes for some files. For example mimetype for css files must be 'text/css' and not 'text/plain' as returned by libmagic. If mimetype is not correct, css files of HTML5 webapps will be not correctly interpreted resulting in a strange rendering in browser like Chrome. Change-Id: I7f0d9f97ede19308c87256f7850f5c51135827f3 Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2017-02-22Enable INFER_EXTENSION and add well-known mime types.Sebastien Douheret1-0/+4
Change-Id: I7c433eea63c01d2b0813a9cc84c12433839bf125 Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2017-01-03Improves naming of session's moduleJosé Bollo1-1/+1
Make names looking like other names Change-Id: I63ce3d8a3d84193eca9d517cecb1888d630a9b2d Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-01-03Adds 2017 to copyrightsJosé Bollo1-1/+1
Change-Id: Id85c4eb4e36a05b61346004ba95daa19faf5074f Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-08-25enforce locale processing for filesJosé Bollo1-0/+107
Change-Id: I7de05d2acd02d088a3a2034ad8bccf524b5b6c12 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-08-25makes a function to ensure trailing slashJosé Bollo1-11/+19
This function is usefull to ensure that links to otherfile are epanded to directory/otherfile (not directoryotherfile!) Change-Id: If8ad1c275598b322516c41706b464d5d90067a8e Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-06-09Make possible to call a method from a bindingJosé Bollo1-1/+9
The new request call 'afb_req_subcall' allows a binding to call the method of an other binding. Change-Id: I8538185be7a1663153a25db2bc940f9e2bdedb1a Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-06-09Events: refactoringJosé Bollo1-3/+12
This new version allows to subscribe a client for an event. The event should first be created for the API (the API's prefix is added) using 'afb_daemon_make_event'. After that, plugins can subscribe or unsubscribe their clients (identified through requests) to the events that it generates. See 'afb_req_subscribe' and 'afb_req_unsubscribe'. Events created by 'afb_daemon_make_event' can be widely broadcasted using 'afb_event_broadcast' or pushed only to suscribers using 'afb_event_push'. Events can be destroyed using 'afb_event_drop'. Change-Id: I7c0bed5e625c2052dcd81c6bfe960def1fa032f3 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-06-08Improves message formatingJosé Bollo1-9/+4
Change-Id: Ifde5ff73cd6a73715fd4d6fd58101d9e97a3bef4 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-06-02afb-hreq.c: fix etag size (fixes stack smashing detected by stack protector)Stephane Desneux1-1/+1
Change-Id: I843dba1d07396ddcfb35b010e7e3a9a9ac73c143 Signed-off-by: Stephane Desneux <stephane.desneux@iot.bzh>
2016-05-29redirect with the queryJosé Bollo1-18/+109
Change-Id: I36c6c6cbc62217ff0d79e004d9b40aa77e3fa0f4 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-05-29compact formatting of jsonJosé Bollo1-2/+2
Change-Id: Ieb839f287593240aac4d784483ff4c6e6cb57d84 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-05-24Improves behaviour of afb_req_getJosé Bollo1-3/+5
The implementations of afb_req_get were not the same for HTTP and WebSocket when the argument wasn't set. Change-Id: I2f09376f597ee75a50b06423a19823040a9352e6 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-05-23fix unicity of returned reqidJosé Bollo1-7/+3
Change-Id: Ib6c56844312112cc20e2c930f5803d620a9cbafc Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-05-23adds 'reqid' for GET/POST requestsJosé Bollo1-13/+27
Change-Id: I222dc17bc9f9795d0931c5a5b90ef53daacd026b Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-05-22Add verbs for closing and setting LOAJosé Bollo1-1/+3
These new verbs are now available to plugins. LOA is the level-of-authorisation. The usage of these new verbs must be protected by a mechanism that is still to be done. Change-Id: Ia591fb6bf9cd16956dc95658c5ba3a24ee4380be Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-05-18favor new names at entry for token and uuidJosé Bollo1-12/+12
Change-Id: I62f9d4df7c83bf8d96ed9d89d4ab4b57146e6bb1 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-05-17provides developper filesJosé Bollo1-1/+2
Change-Id: I0e41a0db778c69b5f5ce71115d495b2bb8b4cffe Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-05-13cleaning copyrightsJosé Bollo1-1/+1
Change-Id: I4ff7349b1a87f92a7d9f378c715054061f06df57 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-05-10explicit use of json-cJosé Bollo1-1/+1
Change-Id: Iebf7309255d1285a5833c5490d32f518a9232ede Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-05-10refactored loggingJosé Bollo1-10/+5
Change-Id: Iec97d679b7e3baa430e614f8e6336d6487de0f25 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-05-10Refactoring requests and context handlingJosé Bollo1-81/+50
Also adds a first (untested) implmentation of the afb services over dbus. Change-Id: Id1bdeccf75f3a70d3658bdaf0510d6e7b97f6c32 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-05-09ensure that the copy is done by libmicrohttpJosé Bollo1-1/+1
Change-Id: I68d10265e34953e3ad21197f616c838b4b8c2bad Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-05-04try to avoid unnecessary copyJosé Bollo1-6/+6
Change-Id: I98cd69133ba3babb2719fad8c7e31c4dcaf1ae97 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-04-27first add of asynchonous handlingJosé Bollo1-0/+12
Change-Id: Id9159d33937dc23342d32892f77998fb8cef0000 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-04-26fix warning signed/unsignedJosé Bollo1-1/+1
Change-Id: Iefff8428c64b1432b95affe09273ce66bc7046ff Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-04-25better handling of lengthsJosé Bollo1-4/+3
Change-Id: Ia5f440bd84d18155dbe26f311c3a070238c17444 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-04-20makes common code unicJosé Bollo1-14/+10
Change-Id: I22de2429c57c1329802b0e5783c725b7b475de79 Signed-off-by: José Bollo <jose.bollo@iot.bzh>