From 75a54d3dfd405a91fc4632af3766dc7cf8257112 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Mon, 6 Mar 2023 04:28:51 +0100 Subject: [PATCH] replace http with net:http, add net module --- http.spl | 14 ++++++++------ net.spl | 8 ++++++++ src/runtime.rs | 4 +++- test.spl | 2 +- 4 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 net.spl diff --git a/http.spl b/http.spl index be89377..f30df29 100644 --- a/http.spl +++ b/http.spl @@ -1,11 +1,14 @@ "stream.spl" import +"net.spl" import -construct http namespace { +"http" net:register + +construct net:http namespace { Request Response } -construct http:Request { +construct net:http:Request { host port method path headers @@ -28,9 +31,9 @@ construct http:Request { body this:=body this } - send { http:Response | with this ; + send { net:http:Response | with this ; def stream this:host this:port StreamTypes:tcp:create =stream - def response http:Response:new =response + def response net:http:Response:new =response this:method:to-bytes stream:write-exact; " " _:to-bytes stream:write-exact; @@ -63,7 +66,7 @@ construct http:Request { } } -construct http:Response { +construct net:http:Response { state-num state-msg headers body @@ -74,4 +77,3 @@ construct http:Response { this } } - diff --git a/net.spl b/net.spl new file mode 100644 index 0000000..2a4499e --- /dev/null +++ b/net.spl @@ -0,0 +1,8 @@ + +construct net namespace { + ; + register { | with name this ; + name "net" dyn-def-field; + this "net" settype =net + } +} diff --git a/src/runtime.rs b/src/runtime.rs index f95d6fb..cb35182 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -833,7 +833,9 @@ impl Type { q.append(&mut VecDeque::from(t.lock_ro().parents.clone())); } for property in to_apply.into_iter().rev() { - object.property_map.insert(property, Value::Null.spl()); + if !object.property_map.contains_key(&property) { + object.property_map.insert(property, Value::Null.spl()); + } } } diff --git a/test.spl b/test.spl index db868e0..936332f 100644 --- a/test.spl +++ b/test.spl @@ -110,7 +110,7 @@ func main { int | with args ; "" println "testing http" println - def req "tudbut.de" 80 "GET" "/" http:Request:new =req + def req "tudbut.de" 80 "GET" "/" net:http:Request:new =req req:send "" println