Exit loop when seen_resp_header

pull/13/head
Soner Tari 6 years ago
parent ef8f2b9c3f
commit 31a9468230

@ -2079,7 +2079,7 @@ pxy_http_reqhdr_filter(struct evbuffer *inbuf, struct evbuffer *outbuf, pxy_conn
{ {
char *line; char *line;
while ((line = evbuffer_readln(inbuf, NULL, EVBUFFER_EOL_CRLF))) { while (!ctx->seen_req_header && (line = evbuffer_readln(inbuf, NULL, EVBUFFER_EOL_CRLF))) {
char *replace = pxy_http_reqhdr_filter_line(line, ctx); char *replace = pxy_http_reqhdr_filter_line(line, ctx);
#ifdef DEBUG_PROXY #ifdef DEBUG_PROXY
log_dbg_level_printf(LOG_DBG_MODE_FINEST, "pxy_http_reqhdr_filter: src line, fd=%d: %s\n", ctx->fd, line); log_dbg_level_printf(LOG_DBG_MODE_FINEST, "pxy_http_reqhdr_filter: src line, fd=%d: %s\n", ctx->fd, line);
@ -2106,32 +2106,27 @@ pxy_http_reqhdr_filter(struct evbuffer *inbuf, struct evbuffer *outbuf, pxy_conn
#endif /* DEBUG_PROXY */ #endif /* DEBUG_PROXY */
evbuffer_add_printf(outbuf, "%s\r\n", ctx->header_str); evbuffer_add_printf(outbuf, "%s\r\n", ctx->header_str);
} }
if (ctx->seen_req_header) {
/* request header complete */
if (ctx->conn->opts->deny_ocsp) {
pxy_ocsp_deny(ctx);
}
break;
}
} }
if (!ctx->seen_req_header) { if (ctx->seen_req_header) {
return; /* request header complete */
} if (ctx->conn->opts->deny_ocsp) {
pxy_ocsp_deny(ctx);
}
// @todo Fix this // @todo Fix this
/* out of memory condition? */ /* out of memory condition? */
if (ctx->enomem) { if (ctx->enomem) {
pxy_conn_free(ctx->conn, 1); pxy_conn_free(ctx->conn, 1);
return; return;
} }
/* no data left after parsing headers? */ /* no data left after parsing headers? */
if (evbuffer_get_length(inbuf) == 0) { if (evbuffer_get_length(inbuf) == 0) {
return; return;
}
evbuffer_add_buffer(outbuf, inbuf);
} }
evbuffer_add_buffer(outbuf, inbuf);
} }
static void static void
@ -2139,7 +2134,7 @@ pxy_http_resphdr_filter(struct evbuffer *inbuf, struct evbuffer *outbuf, pxy_con
{ {
char *line; char *line;
while ((line = evbuffer_readln(inbuf, NULL, EVBUFFER_EOL_CRLF))) { while (!ctx->seen_resp_header && (line = evbuffer_readln(inbuf, NULL, EVBUFFER_EOL_CRLF))) {
char *replace = pxy_http_resphdr_filter_line(line, ctx); char *replace = pxy_http_resphdr_filter_line(line, ctx);
#ifdef DEBUG_PROXY #ifdef DEBUG_PROXY
log_dbg_level_printf(LOG_DBG_MODE_FINEST, "pxy_http_resphdr_filter: dst line, fd=%d: %s\n", ctx->fd, line); log_dbg_level_printf(LOG_DBG_MODE_FINEST, "pxy_http_resphdr_filter: dst line, fd=%d: %s\n", ctx->fd, line);
@ -2160,22 +2155,20 @@ pxy_http_resphdr_filter(struct evbuffer *inbuf, struct evbuffer *outbuf, pxy_con
free(line); free(line);
} }
if (!ctx->seen_resp_header) { if (ctx->seen_resp_header) {
return; // @todo Fix this
} /* out of memory condition? */
if (ctx->enomem) {
// @todo Fix this pxy_conn_free(ctx->conn, 0);
/* out of memory condition? */ return;
if (ctx->enomem) { }
pxy_conn_free(ctx->conn, 0);
return;
}
/* no data left after parsing headers? */ /* no data left after parsing headers? */
if (evbuffer_get_length(inbuf) == 0) { if (evbuffer_get_length(inbuf) == 0) {
return; return;
}
evbuffer_add_buffer(outbuf, inbuf);
} }
evbuffer_add_buffer(outbuf, inbuf);
} }
static void static void

Loading…
Cancel
Save