]> granicus.if.org Git - apache/commitdiff
Some small optimization:
authorChristophe Jaillet <jailletc36@apache.org>
Fri, 1 Dec 2017 22:06:33 +0000 (22:06 +0000)
committerChristophe Jaillet <jailletc36@apache.org>
Fri, 1 Dec 2017 22:06:33 +0000 (22:06 +0000)
   - use 'ap_cstr_casecmpn' instead of 'strncasecmp'
   - use 'apr_table_setn' when parameters are constant
   - avoid some memory allocation if the module can not handle a request

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1816919 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy_uwsgi.c

index 68a36c6ae53a8f00621564d544e0c3fa3f9b3457..e94905f8f2afcb3de861324011511fe9fadb5c06 100644 (file)
@@ -63,7 +63,7 @@ static int uwsgi_canon(request_rec *r, char *url)
     const char *err, *path;
     apr_port_t port = UWSGI_DEFAULT_PORT;
 
-    if (strncasecmp(url, UWSGI_SCHEME "://", sizeof(UWSGI_SCHEME) + 2)) {
+    if (ap_cstr_casecmpn(url, UWSGI_SCHEME "://", sizeof(UWSGI_SCHEME) + 2)) {
         return DECLINED;
     }
     url += sizeof(UWSGI_SCHEME);        /* Keep slashes */
@@ -166,7 +166,7 @@ static int uwsgi_send_headers(request_rec *r, proxy_conn_rec * conn)
         }
         else {
             if (!strcmp(script_name, "/")) {
-                apr_table_set(r->subprocess_env, "SCRIPT_NAME", "");
+                apr_table_setn(r->subprocess_env, "SCRIPT_NAME", "");
             }
         }
     }
@@ -453,13 +453,15 @@ static int uwsgi_handler(request_rec *r, proxy_worker * worker,
     size_t w_len;
     char server_portstr[32];
     char *u_path_info;
-    apr_uri_t *uri = apr_palloc(r->pool, sizeof(*uri));
+    apr_uri_t *uri;
 
-    if (strncasecmp(url, UWSGI_SCHEME "://", sizeof(UWSGI_SCHEME) + 2)) {
+    if (ap_cstr_casecmpn(url, UWSGI_SCHEME "://", sizeof(UWSGI_SCHEME) + 2)) {
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "declining URL %s", url);
         return DECLINED;
     }
 
+    uri = apr_palloc(r->pool, sizeof(*uri));
+
     /* ADD PATH_INFO */
 #if AP_MODULE_MAGIC_AT_LEAST(20111130,0)
     w_len = strlen(worker->s->name);