X-Git-Url: http://nitlanguage.org diff --git a/lib/nitcorn/reactor.nit b/lib/nitcorn/reactor.nit index 88d1cbd..afa0d0a 100644 --- a/lib/nitcorn/reactor.nit +++ b/lib/nitcorn/reactor.nit @@ -81,8 +81,8 @@ class HttpServer # Delegate the responsibility to respond to the `Action` handler.prepare_respond_and_close(request, turi, self) return - else response = new HttpResponse(405) - else response = new HttpResponse(405) + else response = new HttpResponse(404) + else response = new HttpResponse(404) respond response close @@ -148,13 +148,13 @@ class HttpFactory event_base.dispatch end - event_base.destroy + event_base.free end end redef class ServerConfig # Handle to retreive the `HttpFactory` on config change - private var factory: HttpFactory + private var factory: HttpFactory is noinit private init with_factory(factory: HttpFactory) do self.factory = factory end @@ -182,7 +182,8 @@ redef class Sys listeners_count[name, port] = 1 end else - listeners_count[name, port] += 1 + var value = listeners_count[name, port].as(not null) + listeners_count[name, port] = value + 1 end interfac.registered = true @@ -200,7 +201,15 @@ redef class Interfaces redef fun add(e) do super - if vh.server_config != null then sys.listen_on(e, vh.server_config.factory) + var config = virtual_host.server_config + if config != null then register_and_listen(e, config) + end + + # Indirection to `listen_on` and check if this targets all addresses + private fun register_and_listen(e: Interface, config: ServerConfig) + do + listen_on(e, config.factory) + if e.name == "0.0.0.0" or e.name == "::0" then config.default_virtual_host = virtual_host end # TODO remove @@ -210,7 +219,7 @@ redef class VirtualHosts redef fun add(e) do super - for i in e.interfaces do sys.listen_on(i, config.factory) + for i in e.interfaces do e.interfaces.register_and_listen(i, config) end # TODO remove