 +
 +            case RETRY:
 +              return;
++        }
++
++        if (n == 0) { // EOF
++            if (!http_body_is_final(&c->parser)) {
++                /* HTTP parser did not trigger response_complete() callback -- waiting for EOF in
++                   `s_body_identity_eof' state.  This happens when HTTP server does not specify 
++                   Content-Length header field in its response (e.g.: HAProxy 1.5.18 & HTTP/1.0 503).
++                   Speed things up and do not call the parser again with no data. */
++                response_complete(&c->parser);	/* will also handle reconnection */
++                return;
++            }
++            goto reconnect;
          }
  
 -        if (http_parser_execute(&c->parser, &parser_settings, c->buf, n) != n) goto error;
 -        if (n == 0 && !http_body_is_final(&c->parser)) goto error;
-+        if (n == 0) // EOF
-+            goto reconnect;
-+
 +        if (http_parser_execute(&c->parser, &parser_settings, c->buf, n) != n)
 +            goto error;
 +

     switch (lua_type(src, index)) {
         case LUA_TBOOLEAN:
diff -Nura old/src/script.h new/src/script.h
--- old/src/script.h	2017-03-08 17:07:10.481161587 +0100
+++ new/src/script.h	2017-03-08 16:44:01.000000000 +0100
@@ -11,14 +11,14 @@
 
 lua_State *script_create(char *, char *, char **);

 # ------------
 
diff -Nura old/src/ae_epoll.c new/src/ae_epoll.c
--- old/src/ae_epoll.c	2017-03-21 13:39:22.931212007 +0100
+++ new/src/ae_epoll.c	2017-03-21 13:54:51.177383879 +0100
@@ -73,7 +73,7 @@
 
     ee.events = 0;
