OpenSIPS/opensips — pull request #119 by shimaore (2013-11-01 00:56:35+00:00)
Title: mi_json module (new module)

This pull request is mostly to get a proper code review on this proposed new feature.
I need help with proper integration in the build system as well. (I only did the integration for `packaging/debian`.)

This code brings some changes to the existing `httpd` module, which are required to support JSON, namely:
- support for `Accept` request header;
- support for `application/json` in `Accept` and `Content-Type` headers.

This code also includes a new module, `mi_json`, which returns JSON objects to HTTP `GET` requests formatted as `/json/?params=,,...`, where `` is an MI command and `` etc. are the optional arguments. The `Accept` header must be set (mostly because of the way the `httpd` module prevents its users from setting a content-type).
The code tries to be smart about what data is present in the MI response tree, and builds the JSON response accordingly; for example a request for `which` will return a JSON array of strings.
Currently the implementation does not deal properly with async response tree building; it waits until the tree is completely built before sending the response. I'm open to ideas on how to improve this.