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

http: add server.v and organize HTTP request and response code (#10355)

This commit is contained in:
Miccah
2021-06-05 16:43:14 -05:00
committed by GitHub
parent 3f00ff465b
commit c2981de4d5
8 changed files with 651 additions and 246 deletions

View File

@ -499,7 +499,7 @@ pub struct HeaderRenderConfig {
}
// Renders the Header into a string for use in sending
// HTTP requests. All header lines will end in `\n\r`
// HTTP requests. All header lines will end in `\r\n`
[manualfree]
pub fn (h Header) render(flags HeaderRenderConfig) string {
// estimate ~48 bytes per header
@ -524,7 +524,7 @@ pub fn (h Header) render(flags HeaderRenderConfig) string {
}
k := data_keys[data_keys.len - 1]
sb.write_string(h.data[k].join(','))
sb.write_string('\n\r')
sb.write_string('\r\n')
}
} else {
for k, v in h.data {
@ -538,7 +538,7 @@ pub fn (h Header) render(flags HeaderRenderConfig) string {
sb.write_string(key)
sb.write_string(': ')
sb.write_string(v.join(','))
sb.write_string('\n\r')
sb.write_string('\r\n')
}
}
res := sb.str()