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

pull/13/head
Soner Tari 6 years ago
parent 1f451aa04d
commit fcd24a2cbe

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

@ -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); log_dbg_level_printf(LOG_DBG_MODE_FINEST, "prototcp_bev_writecb_src: ENTER, fd=%d\n", ctx->fd);
#endif /* DEBUG_PROXY */ #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 #ifdef DEBUG_PROXY
log_dbg_level_printf(LOG_DBG_MODE_FINEST, "prototcp_bev_writecb_src: Closing redirected conn, fd=%d\n", ctx->fd); 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 */ #endif /* DEBUG_PROXY */
} else {
pxy_conn_term(ctx, 1); #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; return;
} }

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

Loading…
Cancel
Save