nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
model/model_collect: importation_poset do not collect direct parents and children
[nit.git]
/
lib
/
nitcorn
/
reactor.nit
diff --git
a/lib/nitcorn/reactor.nit
b/lib/nitcorn/reactor.nit
index
0fb5cad
..
de9ddc0
100644
(file)
--- a/
lib/nitcorn/reactor.nit
+++ b/
lib/nitcorn/reactor.nit
@@
-35,6
+35,9
@@
class HttpServer
private var parser = new HttpRequestParser is lazy
private var parser = new HttpRequestParser is lazy
+ # Human readable address of the remote client
+ var remote_address: String
+
redef fun read_http_request(str)
do
var request_object = parser.parse_http_request(str.to_s)
redef fun read_http_request(str)
do
var request_object = parser.parse_http_request(str.to_s)
@@
-69,7
+72,7
@@
class HttpServer
request.uri_params = route.parse_params(request.uri)
var handler = route.handler
request.uri_params = route.parse_params(request.uri)
var handler = route.handler
- var root = route.path
+ var root = route.resolve_path(request)
var turi
if root != null then
turi = ("/" + request.uri.substring_from(root.length)).simplify_path
var turi
if root != null then
turi = ("/" + request.uri.substring_from(root.length)).simplify_path
@@
-78,8
+81,8
@@
class HttpServer
# Delegate the responsibility to respond to the `Action`
handler.prepare_respond_and_close(request, turi, self)
return
# 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
respond response
close
@@
-131,7
+134,7
@@
class HttpFactory
# You can use this to create the first `HttpFactory`, which is the most common.
init and_libevent do init(new NativeEventBase)
# You can use this to create the first `HttpFactory`, which is the most common.
init and_libevent do init(new NativeEventBase)
- redef fun spawn_connection(buf_ev) do return new HttpServer(buf_ev, self)
+ redef fun spawn_connection(buf_ev, address) do return new HttpServer(buf_ev, self, address)
# Execute the main listening loop to accept connections
#
# Execute the main listening loop to accept connections
#
@@
-151,7
+154,7
@@
end
redef class ServerConfig
# Handle to retreive the `HttpFactory` on config change
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
private init with_factory(factory: HttpFactory) do self.factory = factory
end
@@
-179,7
+182,8
@@
redef class Sys
listeners_count[name, port] = 1
end
else
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
end
interfac.registered = true
@@
-197,7
+201,8
@@
redef class Interfaces
redef fun add(e)
do
super
redef fun add(e)
do
super
- if vh.server_config != null then sys.listen_on(e, vh.server_config.factory)
+ var config = vh.server_config
+ if config != null then sys.listen_on(e, config.factory)
end
# TODO remove
end
# TODO remove