mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-18 19:50:54 +00:00
MINOR: stream: Use stream type instead of proxy mode when appropriate
We now use the stream instead of the proxy to know if we are processing HTTP data or not. If the stream is an HTX stream, it means we are dealing with HTTP data. It is more accurate than the proxy mode because when an HTTP upgrade is performed, the proxy is not changed and only the stream may be used. Note that it was not a problem to rely on the proxy because HTTP upgrades may only happen when an HTTP backend was set. But, we will add the support of HTTP upgrades on the frontend side, after te tcp-request rules evaluation. In this context, we cannot rely on the proxy mode.
This commit is contained in:
parent
982e17dcf5
commit
1bb6afa35d
@ -1340,7 +1340,7 @@ int connect_server(struct stream *s)
|
||||
si_release_endpoint(&s->si[1]);
|
||||
|
||||
/* do not reuse if mode is not http */
|
||||
if (s->be->mode != PR_MODE_HTTP)
|
||||
if (!IS_HTX_STRM(s))
|
||||
goto skip_reuse;
|
||||
|
||||
/* first, search for a matching connection in the session's idle conns */
|
||||
@ -1576,7 +1576,7 @@ skip_reuse:
|
||||
#if defined(USE_OPENSSL) && defined(TLSEXT_TYPE_application_layer_protocol_negotiation)
|
||||
if (!srv ||
|
||||
(srv->use_ssl != 1 || (!(srv->ssl_ctx.alpn_str) && !(srv->ssl_ctx.npn_str)) ||
|
||||
srv->mux_proto || s->be->mode != PR_MODE_HTTP))
|
||||
srv->mux_proto || !IS_HTX_STRM(s)))
|
||||
#endif
|
||||
init_mux = 1;
|
||||
|
||||
@ -1656,7 +1656,7 @@ skip_reuse:
|
||||
conn_full_close(srv_conn);
|
||||
return SF_ERR_INTERNAL;
|
||||
}
|
||||
if (s->be->mode == PR_MODE_HTTP) {
|
||||
if (IS_HTX_STRM(s)) {
|
||||
/* If we're doing http-reuse always, and the connection
|
||||
* is not private with available streams (an http2
|
||||
* connection), add it to the available list, so that
|
||||
|
16
src/hlua.c
16
src/hlua.c
@ -2952,7 +2952,7 @@ __LJMP static int hlua_channel_dup_yield(lua_State *L, int status, lua_KContext
|
||||
|
||||
chn = MAY_LJMP(hlua_checkchannel(L, 1));
|
||||
|
||||
if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
|
||||
if (IS_HTX_STRM(chn_strm(chn))) {
|
||||
lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
|
||||
WILL_LJMP(lua_error(L));
|
||||
}
|
||||
@ -2982,7 +2982,7 @@ __LJMP static int hlua_channel_get_yield(lua_State *L, int status, lua_KContext
|
||||
|
||||
chn = MAY_LJMP(hlua_checkchannel(L, 1));
|
||||
|
||||
if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
|
||||
if (IS_HTX_STRM(chn_strm(chn))) {
|
||||
lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
|
||||
WILL_LJMP(lua_error(L));
|
||||
}
|
||||
@ -3024,7 +3024,7 @@ __LJMP static int hlua_channel_getline_yield(lua_State *L, int status, lua_KCont
|
||||
|
||||
chn = MAY_LJMP(hlua_checkchannel(L, 1));
|
||||
|
||||
if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
|
||||
if (IS_HTX_STRM(chn_strm(chn))) {
|
||||
lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
|
||||
WILL_LJMP(lua_error(L));
|
||||
}
|
||||
@ -3074,7 +3074,7 @@ __LJMP static int hlua_channel_append_yield(lua_State *L, int status, lua_KConte
|
||||
int ret;
|
||||
int max;
|
||||
|
||||
if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
|
||||
if (IS_HTX_STRM(chn_strm(chn))) {
|
||||
lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
|
||||
WILL_LJMP(lua_error(L));
|
||||
}
|
||||
@ -3148,7 +3148,7 @@ __LJMP static int hlua_channel_set(lua_State *L)
|
||||
chn = MAY_LJMP(hlua_checkchannel(L, 1));
|
||||
lua_pushinteger(L, 0);
|
||||
|
||||
if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
|
||||
if (IS_HTX_STRM(chn_strm(chn))) {
|
||||
lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
|
||||
WILL_LJMP(lua_error(L));
|
||||
}
|
||||
@ -3179,7 +3179,7 @@ __LJMP static int hlua_channel_send_yield(lua_State *L, int status, lua_KContext
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
|
||||
if (IS_HTX_STRM(chn_strm(chn))) {
|
||||
lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
|
||||
WILL_LJMP(lua_error(L));
|
||||
}
|
||||
@ -3290,7 +3290,7 @@ __LJMP static int hlua_channel_forward_yield(lua_State *L, int status, lua_KCont
|
||||
|
||||
chn = MAY_LJMP(hlua_checkchannel(L, 1));
|
||||
|
||||
if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
|
||||
if (IS_HTX_STRM(chn_strm(chn))) {
|
||||
lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
|
||||
WILL_LJMP(lua_error(L));
|
||||
}
|
||||
@ -5505,7 +5505,7 @@ static int hlua_txn_new(lua_State *L, struct stream *s, struct proxy *p, int dir
|
||||
|
||||
/* Creates the HTTP object is the current proxy allows http. */
|
||||
lua_pushstring(L, "http");
|
||||
if (p->mode == PR_MODE_HTTP) {
|
||||
if (IS_HTX_STRM(s)) {
|
||||
if (!hlua_http_new(L, htxn))
|
||||
return 0;
|
||||
}
|
||||
|
@ -918,7 +918,7 @@ static void back_establish(struct stream *s)
|
||||
if (objt_server(s->target))
|
||||
health_adjust(objt_server(s->target), HANA_STATUS_L4_OK);
|
||||
|
||||
if (s->be->mode == PR_MODE_TCP) { /* let's allow immediate data connection in this case */
|
||||
if (!IS_HTX_STRM(s)) { /* let's allow immediate data connection in this case */
|
||||
/* if the user wants to log as soon as possible, without counting
|
||||
* bytes from the server, then this is the right moment. */
|
||||
if (!LIST_ISEMPTY(&strm_fe(s)->logformat) && !(s->logs.logwait & LW_BYTES)) {
|
||||
@ -935,7 +935,7 @@ static void back_establish(struct stream *s)
|
||||
|
||||
/* Be sure to filter response headers if the backend is an HTTP proxy
|
||||
* and if there are filters attached to the stream. */
|
||||
if (s->be->mode == PR_MODE_HTTP && HAS_FILTERS(s))
|
||||
if (IS_HTX_STRM(s) && HAS_FILTERS(s))
|
||||
rep->analysers |= AN_RES_FLT_HTTP_HDRS;
|
||||
|
||||
si_rx_endp_more(si);
|
||||
|
Loading…
Reference in New Issue
Block a user