[hamradio-commits] [dump1090] 364/373: need the actual patch...

Matthew Ernisse mernisse-guest at moszumanska.debian.org
Thu Oct 23 14:58:38 UTC 2014


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

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

commit 3b93887f61b1bb5eff0cc2641c3eefc98ad4bb4e
Author: Matthew Ernisse <mernisse at ub3rgeek.net>
Date:   Sun Oct 19 14:16:58 2014 -0400

    need the actual patch...
---
 debian/patches/02-http-buffer.patch | 89 +++++++++++++++++++++++++++++++++++++
 1 file changed, 89 insertions(+)

diff --git a/debian/patches/02-http-buffer.patch b/debian/patches/02-http-buffer.patch
new file mode 100644
index 0000000..26d4f5e
--- /dev/null
+++ b/debian/patches/02-http-buffer.patch
@@ -0,0 +1,89 @@
+Author: Matthew John Ernisse <mernisse at ub3rgeek.net>
+Description: Add basic buffering to the HTTP server in net_io.c to allow us to
+ serve larger than SO_SNDBUF files.
+Forwarded: no
+
+--- a/net_io.c
++++ b/net_io.c
+@@ -686,6 +686,8 @@
+ //
+ //=========================================================================
+ //
++#define HTTP_OK "200 OK";
++#define HTTP_NOTFOUND "404 Not Found";
+ #define MODES_CONTENT_TYPE_HTML "text/html;charset=utf-8"
+ #define MODES_CONTENT_TYPE_CSS  "text/css;charset=utf-8"
+ #define MODES_CONTENT_TYPE_JSON "application/json;charset=utf-8"
+@@ -701,6 +703,7 @@
+ int handleHTTPRequest(struct client *c, char *p) {
+     char hdr[512];
+     int clen, hdrlen;
++    char *httpcode = HTTP_OK;
+     int httpver, keepalive;
+     char *url, *content;
+     char ctype[48];
+@@ -752,13 +755,17 @@
+         if (stat(getFile, &sbuf) != -1 && (fd = open(getFile, O_RDONLY)) != -1) {
+             content = (char *) malloc(sbuf.st_size);
+             if (read(fd, content, sbuf.st_size) == -1) {
+-                snprintf(content, sbuf.st_size, "Error reading from file: %s", strerror(errno));
++                snprintf(content, sbuf.st_size, "Error reading from %s: %s",
++                    getFile, strerror(errno));
++                httpcode = HTTP_NOTFOUND;
+             }
+             clen = sbuf.st_size;
+         } else {
+             char buf[128];
+-            clen = snprintf(buf,sizeof(buf),"Error opening HTML file: %s", strerror(errno));
++            clen = snprintf(buf, sizeof(buf), "Error opening %s: %s",
++                getFile, strerror(errno));
+             content = strdup(buf);
++            httpcode = HTTP_NOTFOUND;
+         }
+         
+         if (fd != -1) {
+@@ -782,7 +789,7 @@
+ 
+     // Create the header and send the reply
+     hdrlen = snprintf(hdr, sizeof(hdr),
+-        "HTTP/1.1 200 OK\r\n"
++        "HTTP/1.1 %s\r\n"
+         "Server: Dump1090\r\n"
+         "Content-Type: %s\r\n"
+         "Connection: %s\r\n"
+@@ -790,6 +797,7 @@
+         "Cache-Control: no-cache, must-revalidate\r\n"
+         "Expires: Sat, 26 Jul 1997 05:00:00 GMT\r\n"
+         "\r\n",
++        httpcode,
+         ctype,
+         keepalive ? "keep-alive" : "close",
+         clen);
+@@ -800,15 +808,24 @@
+ 
+     // Send header and content.
+ #ifndef _WIN32
+-    if ( (write(c->fd, hdr, hdrlen) != hdrlen) 
+-      || (write(c->fd, content, clen) != clen) ) {
++    if (anetWrite(c->fd, hdr, hdrlen) != hdrlen) {
++        perror("HTTP short write of reply header");
++        free(content);
++        return 1;
++    }
++
++    if (anetWrite(c->fd, content, clen) != clen) {
++        perror("HTTP short write of content");
++        free(content);
++        return 1;
++    }
+ #else
+     if ( (send(c->fd, hdr, hdrlen, 0) != hdrlen) 
+       || (send(c->fd, content, clen, 0) != clen) ) {
+-#endif
+         free(content);
+         return 1;
+     }
++#endif
+     free(content);
+     Modes.stat_http_requests++;
+     return !keepalive;

-- 
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