WSL(sp->wrk, SLT_Debug, vc->fd, "Invalid Transfer-Encoding");
VBE_ClosedFd(sp);
return (__LINE__);
+ } else if (http_HdrIs(hp, H_Connection, "keep-alive")) {
+ /*
+ * If we have Connection: keep-alive, it cannot possibly be
+ * EOF encoded, and since it is neither length nor chunked
+ * it must be zero length.
+ */
+ mklen = 1;
+ } else if (http_HdrIs(hp, H_Connection, "close")) {
+ /*
+ * If we have connection closed, it is safe to read what
+ * comes in any case.
+ */
+ cls = fetch_eof(sp, htc);
+ mklen = 1;
+ } else if (hp->protover < 1.1) {
+ /*
+ * With no Connection header, assume EOF
+ */
+ cls = fetch_eof(sp, htc);
+ mklen = 1;
} else {
- switch (http_GetStatus(hp)) {
- case 200:
- cls = fetch_eof(sp, htc);
- mklen = 1;
- break;
- default:
- break;
- }
+ /*
+ * Assume zero length
+ */
+ mklen = 1;
}
if (cls < 0) {
http_PrintfHeader(sp->wrk, sp->fd, hp2,
"Content-Length: %u", sp->obj->len);
- if (http_GetHdr(hp, H_Connection, &b) && !strcasecmp(b, "close"))
+ if (http_HdrIs(hp, H_Connection, "close"))
cls = 1;
if (cls)
unsigned u;
if (!http_GetHdr(hp, H_Connection, &p)) {
- if (strcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.1"))
+ if (hp->protover < 1.1)
return ("not HTTP/1.1");
return (NULL);
}
return (http_dissect_hdrs(w, hp, fd, p, htc->rxbuf));
}
+/*--------------------------------------------------------------------*/
+
+static void
+http_ProtoVer(struct http *hp)
+{
+
+ if (!strcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.0"))
+ hp->protover = 1.0;
+ else if (!strcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.1"))
+ hp->protover = 1.1;
+ else
+ hp->protover = 0.9;
+}
+
+
/*--------------------------------------------------------------------*/
int
WSPR(sp, SLT_HttpGarbage, htc->rxbuf);
return (i);
}
-
- if (!strcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.0"))
- hp->protover = 1.0;
- else if (!strcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.1"))
- hp->protover = 1.1;
- else
- hp->protover = 0.9;
+ http_ProtoVer(hp);
return (i);
}
hp->status =
strtoul(hp->hd[HTTP_HDR_STATUS].b, NULL /* XXX */, 10);
}
+ http_ProtoVer(hp);
if (hp->hd[HTTP_HDR_RESPONSE].b == NULL ||
!Tlen(hp->hd[HTTP_HDR_RESPONSE])) {
/* Backend didn't send a response string, use the standard */