r15400: Move the TLS code behind the socket interface.
[jelmer/samba4-debian.git] / source / web_server / http.c
index 749e881554d38db10af35d399590f8858b25c83f..f79bedb2de493a3e5e918ce4d131ccb16598abca 100644 (file)
@@ -24,7 +24,7 @@
 #include "smbd/service_task.h"
 #include "web_server/web_server.h"
 #include "smbd/service_stream.h"
-#include "smbd/proto.h"
+#include "smbd/service.h"
 #include "lib/events/events.h"
 #include "system/time.h"
 #include "lib/appweb/esp/esp.h"
@@ -237,12 +237,12 @@ static void http_redirect(EspHandle handle, int code, char *url)
                        char *p = strrchr(web->input.url, '/');
                        if (p == web->input.url) {
                                url = talloc_asprintf(web, "http%s://%s/%s", 
-                                                     tls_enabled(web->tls)?"s":"",
+                                                     tls_enabled(web->conn->socket)?"s":"",
                                                      host, url);
                        } else {
                                int dirlen = p - web->input.url;
                                url = talloc_asprintf(web, "http%s://%s%*.*s/%s",
-                                                     tls_enabled(web->tls)?"s":"",
+                                                     tls_enabled(web->conn->socket)?"s":"",
                                                      host, 
                                                      dirlen, dirlen, web->input.url,
                                                      url);
@@ -452,7 +452,7 @@ static void http_setup_arrays(struct esp_state *esp)
        }
 
        SETVAR(ESP_SERVER_OBJ, "DOCUMENT_ROOT", lp_swat_directory());
-       SETVAR(ESP_SERVER_OBJ, "SERVER_PROTOCOL", tls_enabled(web->tls)?"https":"http");
+       SETVAR(ESP_SERVER_OBJ, "SERVER_PROTOCOL", tls_enabled(web->conn->socket)?"https":"http");
        SETVAR(ESP_SERVER_OBJ, "SERVER_SOFTWARE", "SWAT");
        SETVAR(ESP_SERVER_OBJ, "GATEWAY_INTERFACE", "CGI/1.1");
        SETVAR(ESP_SERVER_OBJ, "TLS_SUPPORT", tls_support(edata->tls_params)?"True":"False");
@@ -467,7 +467,7 @@ static void http_setup_arrays(struct esp_state *esp)
 static jmp_buf ejs_exception_buf;
 static const char *exception_reason;
 
-void ejs_exception(const char *reason)
+static void web_server_ejs_exception(const char *reason)
 {
        Ejs *ep = ejsPtr(0);
        if (ep) {
@@ -480,7 +480,7 @@ void ejs_exception(const char *reason)
        longjmp(ejs_exception_buf, -1);
 }
 #else
-void ejs_exception(const char *reason)
+static void web_server_ejs_exception(const char *reason)
 {
        DEBUG(0,("%s", reason));
        smb_panic(reason);
@@ -804,7 +804,7 @@ void http_process_input(struct websrv_context *web)
                           edata->application_data, MPR_DEEP_COPY);
        }
 
-       smb_setup_ejs_functions();
+       smb_setup_ejs_functions(web_server_ejs_exception);
 
        if (web->input.url == NULL) {
                http_error(web, 400, "You must specify a GET or POST request");