From 6e1eeac3b33db5e2f71b51cf6b69cb15b931d393 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 15 Oct 2010 10:41:58 -0700 Subject: [PATCH] rgw: small cleanup --- src/rgw/rgw_rest.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index 44b6a4b637a..fccc8b0b2cd 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -611,6 +611,16 @@ static void init_auth_info(struct req_state *s) } } +static int str_to_bool(const char *s, int def_val) +{ + if (!s) + return def_val; + + return (strcasecmp(s, "on") == 0 || + strcasecmp(s, "yes") == 0 || + strcasecmp(s, "1")); +} + void RGWHandler_REST::provider_init_state() { s->path_name = FCGX_GetParam("SCRIPT_NAME", s->fcgx->envp); @@ -650,7 +660,7 @@ void RGWHandler_REST::provider_init_state() s->http_auth = FCGX_GetParam("HTTP_AUTHORIZATION", s->fcgx->envp); const char *cgi_env_continue = FCGX_GetParam("RGW_PRINT_CONTINUE", s->fcgx->envp); - if (cgi_env_continue != NULL && strcasecmp(cgi_env_continue, "On") == 0) { + if (str_to_bool(cgi_env_continue, 0)) { const char *expect = FCGX_GetParam("HTTP_EXPECT", s->fcgx->envp); s->expect_cont = (expect && !strcasecmp(expect, "100-continue")); }