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

vweb: fix headers

This commit is contained in:
Carlos Esquerdo Bernat
2019-09-05 14:46:24 +02:00
committed by Alexander Medvednikov
parent f83bc9528d
commit 8a77d4482c
4 changed files with 126 additions and 124 deletions

View File

@ -13,7 +13,6 @@ const (
struct Request {
pub:
headers2 []string
headers map[string]string
method string
// cookies map[string]string
@ -98,6 +97,21 @@ pub fn (req mut Request) add_header(key, val string) {
// req.h = h
}
pub fn parse_headers(lines []string) map[string]string {
mut headers := map[string]string
for i, line in lines {
if i == 0 {
continue
}
words := line.split(': ')
if words.len != 2 {
continue
}
headers[words[0]] = words[1]
}
return headers
}
pub fn (req &Request) do() ?Response {
if req.typ == 'POST' {
// req.headers << 'Content-Type: application/x-www-form-urlencoded'

View File

@ -19,7 +19,6 @@ fn test_http_get() {
*/
}
fn test_http_get_from_vlang_utc_now() {
/*
urls := ['http://vlang.io/utc_now', 'https://vlang.io/utc_now']