Hi

Some CGI apps like cgit aren't fully compliant. With this patch cgit works with 
monkey.

- Lauri
>From 79a86b16fe593d6d7e597e54c74861ee9661a9f2 Mon Sep 17 00:00:00 2001
From: Lauri Kasanen <[email protected]>
Date: Sat, 15 Dec 2012 21:51:03 +0200
Subject: [PATCH] cgi: Support some non-compliant CGI programs (cgit uses LFLF 
after headers)


Signed-off-by: Lauri Kasanen <[email protected]>
---
 plugins/cgi/event.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/plugins/cgi/event.c b/plugins/cgi/event.c
index 7961516..0c0f015 100644
--- a/plugins/cgi/event.c
+++ b/plugins/cgi/event.c
@@ -98,9 +98,15 @@ int _mkp_event_write(int socket)
 
         if (!r->all_headers_done)
         {
+            unsigned char advance = 4;
+
             // Write the rest of the headers without chunking
             char *end = strstr(outptr, MK_IOV_CRLFCRLF);
             if (!end) end = strstr(outptr, MK_IOV_LFLFLFLF);
+            if (!end) {
+                end = strstr(outptr, MK_IOV_LFLF);
+                advance = 2;
+            }
             if (!end)
             {
                 swrite(socket, outptr, r->in_len);
@@ -109,7 +115,7 @@ int _mkp_event_write(int socket)
                 return MK_PLUGIN_RET_EVENT_OWNED;
             }
 
-            end += 4;
+            end += advance;
 
             int len = end - outptr;
 
-- 
1.7.2.1

_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey

Reply via email to