Do not terminate redirected connection until src outbuf is empty, otherwise 302 redirection may not have been sent yet

This commit is contained in:
Soner Tari 2019-03-05 19:01:53 +03:00
parent 1f451aa04d
commit fcd24a2cbe
3 changed files with 10 additions and 6 deletions

View File

@ -534,7 +534,6 @@ protohttp_bev_readcb_src(struct bufferevent *bev, pxy_conn_ctx_t *ctx)
} else {
evbuffer_add_printf(bufferevent_get_output(bev), redirect, ctx->opts->user_auth_url);
}
ctx->redirected = 1;
return;
}

View File

@ -385,12 +385,18 @@ prototcp_bev_writecb_src(struct bufferevent *bev, pxy_conn_ctx_t *ctx)
log_dbg_level_printf(LOG_DBG_MODE_FINEST, "prototcp_bev_writecb_src: ENTER, fd=%d\n", ctx->fd);
#endif /* DEBUG_PROXY */
if (ctx->opts->user_auth && !ctx->user && ctx->redirected) {
if (ctx->opts->user_auth && !ctx->user) {
size_t outbuflen = evbuffer_get_length(bufferevent_get_output(bev));
if (outbuflen > 0) {
#ifdef DEBUG_PROXY
log_dbg_level_printf(LOG_DBG_MODE_FINEST, "prototcp_bev_writecb_src: Not closing redirected conn, outbuflen=%zu, fd=%d\n", outbuflen, ctx->fd);
#endif /* DEBUG_PROXY */
} else {
#ifdef DEBUG_PROXY
log_dbg_level_printf(LOG_DBG_MODE_FINEST, "prototcp_bev_writecb_src: Closing redirected conn, fd=%d\n", ctx->fd);
#endif /* DEBUG_PROXY */
pxy_conn_term(ctx, 1);
}
return;
}

View File

@ -279,7 +279,6 @@ struct pxy_conn_ctx {
unsigned int identify_user_count;
char *user;
char *ether;
unsigned int redirected : 1;
#ifdef HAVE_LOCAL_PROCINFO
/* local process information */