forked from vieter-v/vieter
Wait for chunked stream WIP [CI SKIP]
parent
e6a1d32f0e
commit
275227400f
|
@ -4,4 +4,5 @@ import docker
|
||||||
|
|
||||||
fn build() {
|
fn build() {
|
||||||
println(docker.pull('archlinux', 'latest') or { panic('yeetus') })
|
println(docker.pull('archlinux', 'latest') or { panic('yeetus') })
|
||||||
|
// println(docker.containers() or { panic('heet') })
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,15 @@ fn send(req &string) ?http.Response {
|
||||||
// Write the request to the socket
|
// Write the request to the socket
|
||||||
s.write_string(req) ?
|
s.write_string(req) ?
|
||||||
|
|
||||||
// Wait for the server to respond
|
|
||||||
s.wait_for_write() ?
|
|
||||||
|
|
||||||
mut buf := []byte{len: docker.buf_len}
|
mut buf := []byte{len: docker.buf_len}
|
||||||
mut res := []byte{}
|
mut res := []byte{}
|
||||||
|
|
||||||
mut c := 0
|
mut c := 0
|
||||||
|
|
||||||
|
for res.len < 5 && res#[-4..] != [0, '\r', `\n`, `\r`, `\n`] {
|
||||||
|
// Wait for the server to respond
|
||||||
|
s.wait_for_write() ?
|
||||||
|
|
||||||
for {
|
for {
|
||||||
c = s.read(mut buf) or { return error('Failed to read data from socket.') }
|
c = s.read(mut buf) or { return error('Failed to read data from socket.') }
|
||||||
res << buf[..c]
|
res << buf[..c]
|
||||||
|
@ -39,6 +40,9 @@ fn send(req &string) ?http.Response {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
println(res)
|
||||||
|
|
||||||
// Decode chunked response
|
// Decode chunked response
|
||||||
return http.parse_response(res.bytestr())
|
return http.parse_response(res.bytestr())
|
||||||
|
|
Loading…
Reference in New Issue