Commit 8dc74833 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Rewrite the H1 header fetch without SES_Rx(), this makes it simpler.

parent f4053ac0
......@@ -979,7 +979,6 @@ enum htc_status_e {
void SES_RxInit(struct http_conn *htc, struct ws *ws,
unsigned maxbytes, unsigned maxhdr);
void SES_RxReInit(struct http_conn *htc);
enum htc_status_e SES_Rx(struct http_conn *htc, double tmo);
enum htc_status_e SES_RxStuff(struct http_conn *, htc_complete_f *,
double *t1, double *t2, double ti, double tn);
......
......@@ -189,32 +189,6 @@ SES_RxReInit(struct http_conn *htc)
*htc->rxbuf_e = '\0';
}
/*--------------------------------------------------------------------
* Receive more HTTP protocol bytes
*/
enum htc_status_e
SES_Rx(struct http_conn *htc, double tmo)
{
int i;
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
AN(htc->ws->r);
AZ(htc->pipeline_b);
AZ(htc->pipeline_e);
i = (htc->ws->r - htc->rxbuf_e) - 1; /* space for NUL */
if (i <= 0)
return (HTC_S_OVERFLOW);
i = VTCP_read(htc->fd, htc->rxbuf_e, i, tmo);
if (i == -2)
return (HTC_S_TIMEOUT);
if (i <= 0)
return (HTC_S_EOF);
htc->rxbuf_e += i;
*htc->rxbuf_e = '\0';
return (HTC_S_MORE);
}
/*----------------------------------------------------------------------
* Receive a request/packet/whatever, with timeouts
*
......
......@@ -137,7 +137,6 @@ V1F_FetchRespHdr(struct busyobj *bo)
{
struct http *hp;
enum htc_status_e hs;
int first, i;
struct http_conn *htc;
......@@ -160,23 +159,22 @@ V1F_FetchRespHdr(struct busyobj *bo)
first = 1;
do {
hs = SES_Rx(htc, 0);
if (hs == HTC_S_MORE)
hs = HTTP1_Complete(htc);
if (hs == HTC_S_OVERFLOW) {
WS_ReleaseP(htc->ws, htc->rxbuf_b);
i = (htc->ws->r - htc->rxbuf_e) - 1; /* space for NUL */
if (i <= 0) {
bo->acct.beresp_hdrbytes +=
htc->rxbuf_e - htc->rxbuf_b;
WS_ReleaseP(htc->ws, htc->rxbuf_b);
VSLb(bo->vsl, SLT_FetchError,
"http %sread error: overflow",
first ? "first " : "");
htc->doclose = SC_RX_OVERFLOW;
return (-1);
}
if (hs == HTC_S_EOF) {
WS_ReleaseP(htc->ws, htc->rxbuf_b);
i = read(htc->fd, htc->rxbuf_e, i);
if (i <= 0) {
bo->acct.beresp_hdrbytes +=
htc->rxbuf_e - htc->rxbuf_b;
WS_ReleaseP(htc->ws, htc->rxbuf_b);
VSLb(bo->vsl, SLT_FetchError, "http %sread error: EOF",
first ? "first " : "");
htc->doclose = SC_RX_TIMEOUT;
......@@ -187,7 +185,10 @@ V1F_FetchRespHdr(struct busyobj *bo)
VTCP_set_read_timeout(htc->fd,
htc->between_bytes_timeout);
}
} while (hs != HTC_S_COMPLETE);
htc->rxbuf_e += i;
*htc->rxbuf_e = '\0';
} while (HTTP1_Complete(htc) != HTC_S_COMPLETE);
WS_ReleaseP(htc->ws, htc->rxbuf_e);
hp = bo->beresp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment