changeset 1503:fa67e7914b70 stable-0.5

r1391, r1392, r1393 merge: auth_http related changes: *) stop configuration on error *) allow "http://" in auth_http URL *) test http_auth absence
author Igor Sysoev <igor@sysoev.ru>
date Sat, 22 Sep 2007 18:41:35 +0000
parents 4fd0907c968e
children 840b81d13a2f
files src/mail/ngx_mail_auth_http_module.c
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/mail/ngx_mail_auth_http_module.c
+++ b/src/mail/ngx_mail_auth_http_module.c
@@ -21,6 +21,9 @@ typedef struct {
     ngx_str_t                       header;
 
     ngx_array_t                    *headers;
+
+    u_char                         *file;
+    ngx_uint_t                      line;
 } ngx_mail_auth_http_conf_t;
 
 
@@ -1311,6 +1314,9 @@ ngx_mail_auth_http_create_conf(ngx_conf_
 
     ahcf->timeout = NGX_CONF_UNSET_MSEC;
 
+    ahcf->file = cf->conf_file->file.name.data;
+    ahcf->line = cf->conf_file->line;
+
     return ahcf;
 }
 
@@ -1330,6 +1336,14 @@ ngx_mail_auth_http_merge_conf(ngx_conf_t
         conf->peer = prev->peer;
         conf->host_header = prev->host_header;
         conf->uri = prev->uri;
+
+        if (conf->peer == NULL) {
+            ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+                          "no \"http_auth\" is defined for server in %s:%ui",
+                          conf->file, conf->line);
+
+            return NGX_CONF_ERROR;
+        }
     }
 
     ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000);
@@ -1383,11 +1397,18 @@ ngx_mail_auth_http(ngx_conf_t *cf, ngx_c
     u.uri_part = 1;
     u.one_addr = 1;
 
+    if (ngx_strncmp(u.url.data, "http://", 7) == 0) {
+        u.url.len -= 7;
+        u.url.data += 7;
+    }
+
     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);
         }
+
+        return NGX_CONF_ERROR;
     }
 
     ahcf->peer = u.addrs;