replace http with net:http, add net module
This commit is contained in:
parent
e093c11558
commit
75a54d3dfd
4 changed files with 20 additions and 8 deletions
14
http.spl
14
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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
8
net.spl
Normal file
8
net.spl
Normal file
|
@ -0,0 +1,8 @@
|
|||
|
||||
construct net namespace {
|
||||
;
|
||||
register { | with name this ;
|
||||
name "net" dyn-def-field;
|
||||
this "net" settype =net
|
||||
}
|
||||
}
|
|
@ -833,9 +833,11 @@ impl Type {
|
|||
q.append(&mut VecDeque::from(t.lock_ro().parents.clone()));
|
||||
}
|
||||
for property in to_apply.into_iter().rev() {
|
||||
if !object.property_map.contains_key(&property) {
|
||||
object.property_map.insert(property, Value::Null.spl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_property(&mut self, name: String, origin: Arc<Frame>) -> OError {
|
||||
let tmpname = name.clone();
|
||||
|
|
2
test.spl
2
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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue