replace http with net:http, add net module

This commit is contained in:
Daniella 2023-03-06 04:28:51 +01:00
parent e093c11558
commit 75a54d3dfd
Signed by: TudbuT
GPG key ID: 7D63D5634B7C417F
4 changed files with 20 additions and 8 deletions

View file

@ -1,11 +1,14 @@
"stream.spl" import "stream.spl" import
"net.spl" import
construct http namespace { "http" net:register
construct net:http namespace {
Request Request
Response Response
} }
construct http:Request { construct net:http:Request {
host port host port
method path method path
headers headers
@ -28,9 +31,9 @@ construct http:Request {
body this:=body body this:=body
this this
} }
send { http:Response | with this ; send { net:http:Response | with this ;
def stream this:host this:port StreamTypes:tcp:create =stream 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; this:method:to-bytes stream:write-exact;
" " _: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 state-num state-msg
headers headers
body body
@ -74,4 +77,3 @@ construct http:Response {
this this
} }
} }

8
net.spl Normal file
View file

@ -0,0 +1,8 @@
construct net namespace {
;
register { | with name this ;
name "net" dyn-def-field;
this "net" settype =net
}
}

View file

@ -833,9 +833,11 @@ impl Type {
q.append(&mut VecDeque::from(t.lock_ro().parents.clone())); q.append(&mut VecDeque::from(t.lock_ro().parents.clone()));
} }
for property in to_apply.into_iter().rev() { for property in to_apply.into_iter().rev() {
if !object.property_map.contains_key(&property) {
object.property_map.insert(property, Value::Null.spl()); object.property_map.insert(property, Value::Null.spl());
} }
} }
}
pub fn add_property(&mut self, name: String, origin: Arc<Frame>) -> OError { pub fn add_property(&mut self, name: String, origin: Arc<Frame>) -> OError {
let tmpname = name.clone(); let tmpname = name.clone();

View file

@ -110,7 +110,7 @@ func main { int | with args ;
"" println "" println
"testing http" 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 req:send
"" println "" println