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:

committed by
Alexander Medvednikov

parent
f83bc9528d
commit
8a77d4482c
@ -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'
|
||||
|
@ -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']
|
||||
|
Reference in New Issue
Block a user