[hamradio-commits] [dump1090] 329/389: B"H net_io.c: http serve: return HTTP response codes

Matthew Ernisse mernisse-guest at moszumanska.debian.org
Wed Nov 5 00:20:11 UTC 2014


This is an automated email from the git hooks/post-receive script.

mernisse-guest pushed a commit to branch master
in repository dump1090.

commit 8d307cd0ebe8ac2b446d717d048dc11951c3eb29
Author: hhm <heehooman+vcs-ci at gmail.com>
Date:   Wed Sep 17 06:32:03 2014 -0400

    B"H net_io.c: http serve: return HTTP response codes
---
 net_io.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net_io.c b/net_io.c
index 1679ef1..91cf47d 100644
--- a/net_io.c
+++ b/net_io.c
@@ -695,6 +695,7 @@ int handleHTTPRequest(struct client *c, char *p) {
     char hdr[512];
     int clen, hdrlen;
     int httpver, keepalive;
+    int statuscode = 500;
     char *url, *content;
     char ctype[48];
     char getFile[1024];
@@ -736,6 +737,7 @@ int handleHTTPRequest(struct client *c, char *p) {
     // "/" -> Our google map application.
     // "/data.json" -> Our ajax request to update planes.
     if (strstr(url, "/data.json")) {
+        statuscode = 200;
         content = aircraftsToJson(&clen);
         //snprintf(ctype, sizeof ctype, MODES_CONTENT_TYPE_JSON);
     } else {
@@ -753,6 +755,7 @@ int handleHTTPRequest(struct client *c, char *p) {
                 content = (char *) malloc(sbuf.st_size);
                 if (read(fd, content, sbuf.st_size) != -1) {
                     clen = sbuf.st_size;
+                    statuscode = 200;
 				} else {
 					free(content);
                 }
@@ -764,6 +767,7 @@ int handleHTTPRequest(struct client *c, char *p) {
         if (clen < 0) {
             char buf[128];
             clen = snprintf(buf,sizeof(buf),"Error opening HTML file: %s", strerror(errno));
+            statuscode = 404;
             content = strdup(buf);
         }
         
@@ -788,7 +792,7 @@ int handleHTTPRequest(struct client *c, char *p) {
 
     // Create the header and send the reply
     hdrlen = snprintf(hdr, sizeof(hdr),
-        "HTTP/1.1 200 OK\r\n"
+        "HTTP/1.1 %i \r\n"
         "Server: Dump1090\r\n"
         "Content-Type: %s\r\n"
         "Connection: %s\r\n"
@@ -796,6 +800,7 @@ int handleHTTPRequest(struct client *c, char *p) {
         "Cache-Control: no-cache, must-revalidate\r\n"
         "Expires: Sat, 26 Jul 1997 05:00:00 GMT\r\n"
         "\r\n",
+		statuscode,
         ctype,
         keepalive ? "keep-alive" : "close",
         clen);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/dump1090.git



More information about the pkg-hamradio-commits mailing list