fixe trailing space and empty lines
[psensor.git] / src / server / server.c
index 673964c..9c922c9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2010-2011 wpitchoune@gmail.com
+    Copyright (C) 2010-2011 jeanfi@gmail.com
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -77,7 +77,7 @@ static int server_stop_requested;
 void print_version()
 {
        printf("psensor-server %s\n", VERSION);
-       printf(_("Copyright (C) %s wpitchoune@gmail.com\n\
+       printf(_("Copyright (C) %s jeanfi@gmail.com\n\
 License GPLv2: GNU GPL version 2 or later \
 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n\
 This is free software: you are free to change and redistribute it.\n\
@@ -160,6 +160,8 @@ create_response_api(const char *nurl,
                    const char *method,
                    unsigned int *rp_code)
 {
+       struct MHD_Response *resp;
+       struct psensor *s;
        char *page = NULL;
 
        if (!strcmp(nurl, URL_BASE_API_1_0_SENSORS))  {
@@ -172,8 +174,7 @@ create_response_api(const char *nurl,
 
                const char *sid = nurl + strlen(URL_BASE_API_1_0_SENSORS) + 1;
 
-               struct psensor *s
-                       = psensor_list_get_by_id(server_data.sensors, sid);
+               s = psensor_list_get_by_id(server_data.sensors, sid);
 
                if (s)
                        page = sensor_to_json_string(s);
@@ -188,8 +189,13 @@ create_response_api(const char *nurl,
        if (page) {
                *rp_code = MHD_HTTP_OK;
 
-               return MHD_create_response_from_data
-                       (strlen(page), page, MHD_YES, MHD_NO);
+               resp = MHD_create_response_from_data(strlen(page), page,
+                                                    MHD_YES, MHD_NO);
+
+               MHD_add_response_header(resp, MHD_HTTP_HEADER_CONTENT_TYPE,
+                                       "application/json");
+
+               return resp;
        }
 
        return NULL;