summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/rest/common.php
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2017-05-08 08:32:05 +0000
committerramon <ramongomez@us.es>2017-05-08 08:32:05 +0000
commit8ba8712f288bf4d6a56249c21905058241ab654a (patch)
tree2160526370bf3add5b47e16c73f82f51ba47407d /admin/WebConsole/rest/common.php
parentcff57e676f8c5a944634cf2a9d8e7d98c4127c89 (diff)
#718: Creada función para devolver respuesta JSON a agente OGAgent y continuar procesando; revisar que el cliente está en la BD y marcado como reservado antes de redirigir notificaciones al servidor UDS.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5287 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/WebConsole/rest/common.php')
-rw-r--r--admin/WebConsole/rest/common.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/admin/WebConsole/rest/common.php b/admin/WebConsole/rest/common.php
index d65a9c52..71778e8b 100644
--- a/admin/WebConsole/rest/common.php
+++ b/admin/WebConsole/rest/common.php
@@ -31,6 +31,32 @@ function jsonResponse($status, $response, $opts=0) {
}
/**
+ * @brief Print immediately JSON response to continue processing.
+ * @param int status Status code for HTTP response.
+ * @param array response Response data.
+ * @param int opts Options to encode JSON data.
+ * @return string JSON response.
+ */
+function jsonResponseNow($status, $response, $opts=0) {
+ // Flush buffer.
+ ob_end_clean();
+ ob_end_flush();
+ header("Connection: close");
+ // Compose headers and content.
+ http_response_code((int)$status);
+ header('Content-type: application/json; charset=utf-8');
+ ignore_user_abort();
+ ob_start();
+ echo json_encode($response, $opts);
+ $size = ob_get_length();
+ header("Content-Length: $size");
+ // Print content.
+ ob_end_flush();
+ flush();
+ session_write_close();
+}
+
+/**
* @brief Validate API key included in "Authorization" HTTP header.
* @return JSON response on error.
*/