]> git.kaiwu.me - nginx.git/commitdiff
now the "auth_http" directive uses ngx_parse_url()
authorIgor Sysoev <igor@sysoev.ru>
Tue, 24 Oct 2006 13:22:59 +0000 (13:22 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 24 Oct 2006 13:22:59 +0000 (13:22 +0000)
src/imap/ngx_imap_auth_http_module.c

index fd9bb5352e1dc8b30eaec6311e32325ba7f17932..774405a0a75d11e1fe763d4645175eaeab8096b7 100644 (file)
@@ -1247,61 +1247,29 @@ ngx_imap_auth_http(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 {
     ngx_imap_auth_http_conf_t *ahcf = conf;
 
-    ngx_str_t                   *value, *url;
-    ngx_inet_upstream_t          inet_upstream;
-#if (NGX_HAVE_UNIX_DOMAIN)
-    ngx_unix_domain_upstream_t   unix_upstream;
-#endif
+    ngx_str_t  *value;
+    ngx_url_t   u;
 
     value = cf->args->elts;
 
-    url = &value[1];
-
-    if (ngx_strncasecmp(url->data, "unix:", 5) == 0) {
-
-#if (NGX_HAVE_UNIX_DOMAIN)
+    ngx_memzero(&u, sizeof(ngx_url_t));
 
-        ngx_memzero(&unix_upstream, sizeof(ngx_unix_domain_upstream_t));
+    u.url = value[1];
+    u.default_portn = 80;
+    u.uri_part = 1;
 
-        unix_upstream.name = *url;
-        unix_upstream.url = *url;
-        unix_upstream.uri_part = 1;
-
-        ahcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream);
-        if (ahcf->peers == NULL) {
-            return NGX_CONF_ERROR;
-        }
-
-        ahcf->host_header.len = sizeof("localhost") - 1;
-        ahcf->host_header.data = (u_char *) "localhost";
-        ahcf->uri = unix_upstream.uri;
-
-#else
-        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
-                           "the unix domain sockets are not supported "
-                           "on this platform");
-        return NGX_CONF_ERROR;
-
-#endif
-
-    } else {
-        ngx_memzero(&inet_upstream, sizeof(ngx_inet_upstream_t));
-
-        inet_upstream.name = *url;
-        inet_upstream.url = *url;
-        inet_upstream.default_port_value = 80;
-        inet_upstream.uri_part = 1;
-
-        ahcf->peers = ngx_inet_upstream_parse(cf, &inet_upstream);
-        if (ahcf->peers == NULL) {
-            return NGX_CONF_ERROR;
+    if (ngx_parse_url(cf, &u) != NGX_OK) {
+        if (u.err) {
+            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                               "%s in auth_http \"%V\"", u.err, &u.url);
         }
+    }
 
-        ahcf->peers->number = 1;
+    ahcf->peers = u.peers;
+    ahcf->peers->number = 1;
 
-        ahcf->host_header = inet_upstream.host_header;
-        ahcf->uri = inet_upstream.uri;
-    }
+    ahcf->host_header = u.host_header;
+    ahcf->uri = u.uri;
 
     if (ahcf->uri.len == 0) {
         ahcf->uri.len = sizeof("/") - 1;