Is there any way to accomplish w/o using notes? It's not that
they are especially slow, it's just that they aren't that fast
and, iirc, this could be a tight path.

On Apr 4, 2014, at 1:02 PM, Yann Ylavic <ylavic....@gmail.com> wrote:

> Hi,
> 
> this is the day of resurrections :p
> 
> I think I've got a simpler way to address this issue, that is, don't
> send unexpected 100-continue to clients due to proxy ping feature.
> 
> Here is the patch.
> Once again, please object if you don't want me to commit this stuff.
> 
> Reagrds,
> Yann.
> 
> Index: modules/proxy/proxy_util.c
> ===================================================================
> --- modules/proxy/proxy_util.c    (revision 1584652)
> +++ modules/proxy/proxy_util.c    (working copy)
> @@ -3312,8 +3312,43 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_poo
>      * to backend
>      */
>     if (do_100_continue) {
> -        apr_table_mergen(r->headers_in, "Expect", "100-Continue");
> -        r->expecting_100 = 1;
> +        const char *val;
> +
> +        /* Since we may modify the original "proxy-interim-response" env but
> +         * also come back here later with the same request (previous ping
> +         * failure, load balancing recoverable error...), we use "\n" as the
> +         * saved value when the original one is not defined, so that we can 
> do
> +         * the right thing (unset) to restore the env (later) in this case.
> +         */
> +        val = apr_table_get(r->notes, "proxy-interim-pong");
> +        if (val == NULL) {
> +            val = apr_table_get(r->subprocess_env, "proxy-interim-response");
> +            if (val != NULL) {
> +                apr_table_setn(r->notes, "proxy-interim-pong", val);
> +            }
> +            else {
> +                apr_table_setn(r->notes, "proxy-interim-pong", "\n");
> +            }
> +        }
> +        if (!r->expecting_100) {
> +            /* Don't forward any "100 Continue" response if the client is
> +             * not expecting it. */
> +            val = "Suppress";
> +        }
> +        if (val && (val[0] != '\n' || val[1] != '\0')) {
> +            apr_table_setn(r->subprocess_env, "proxy-interim-response", val);
> +        }
> +        else {
> +            apr_table_unset(r->subprocess_env, "proxy-interim-response");
> +        }
> +
> +        /* Add the Expect header if not already there. */
> +        val = apr_table_get(r->headers_in, "Expect");
> +        if ((val == NULL)
> +                || (strcasecmp(val, "100-Continue") != 0 // fast path
> +                    && !ap_find_token(r->pool, val, "100-Continue"))) {
> +            apr_table_mergen(r->headers_in, "Expect", "100-Continue");
> +        }
>     }
> 
>     /* X-Forwarded-*: handling
> [EOS]
> 

Reply via email to