1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vweb: fix headers and cookies

This commit is contained in:
Alexander Medvednikov
2019-12-07 00:44:22 +03:00
parent cc834dd7a7
commit 329485d4b6
3 changed files with 33 additions and 9 deletions

View File

@ -312,6 +312,19 @@ pub fn (s Socket) read_line() string {
return res
}
// TODO
pub fn (s Socket) read_all() string {
mut buf := [MAX_READ]byte // where C.recv will store the network data
mut res := '' // The final result, including the ending \n.
for {
n := C.recv(s.sockfd, buf, MAX_READ-1, 0)
if n == -1 { return res }
if n == 0 { return res }
res += tos_clone(buf)
}
return res
}
pub fn (s Socket) get_port() int {
mut addr := C.sockaddr_in {}
size := 16 // sizeof(sockaddr_in)