diff -urN squid-2.5.STABLE12/src/icap_respmod.c squid-2.5.STABLE12-closebeforesendfix/src/icap_respmod.c --- squid-2.5.STABLE12/src/icap_respmod.c 2006-01-05 16:26:37.000000000 +0000 +++ squid-2.5.STABLE12-closebeforesendfix/src/icap_respmod.c 2006-01-05 16:52:42.000000000 +0000 @@ -252,6 +252,16 @@ #endif if (icap->sc == 0) { + // http connection has been closed without sending us anything + if(len == 0 && theEnd == 1) { + ErrorState *err; + err = errorCon(ERR_INVALID_RESP, HTTP_BAD_GATEWAY); + err->request = requestLink(icap->request); + errorAppendEntry(icap->respmod.entry, err); + comm_close(icap->icap_fd); + return; + } + /* No data sent yet. Start with headers */ if ((icap->sc = buildRespModHeader(&mb, icap, buf, len, theEnd)) > 0) { buf += icap->sc;