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

http: fix cookies

This commit is contained in:
Alexander Medvednikov
2020-07-26 15:54:18 +02:00
parent 88345d759a
commit cf4235ab65
3 changed files with 18 additions and 8 deletions

View File

@ -38,6 +38,7 @@ fn (req &Request) ssl_do(port int, method, host_name, path string) ?Response {
res = C.SSL_get_verify_result(ssl)
// /////
req_headers := req.build_request_headers(method, host_name, path)
//println(req_headers)
C.BIO_puts(web, req_headers.str)
mut content := strings.new_builder(100)
mut buff := [bufsize]byte

View File

@ -49,7 +49,7 @@ pub:
pub fn new_request(method, url_, data string) ?Request {
url := if method == 'GET' { url_ + '?' + data } else { url_ }
//println('new req() method=$method url="$url" dta="$data"')
println('new req() method=$method url="$url" dta="$data"')
return Request{
method: method.to_upper()
url: url
@ -364,7 +364,7 @@ fn (req &Request) build_request_headers(method, host_name, path string) string {
if key == 'Cookie' {
continue
}
uheaders << '${key}: ${val}\r\n'
uheaders << '${key}=${val}\r\n'
}
uheaders << req.build_request_cookies_header()
return '$method $path HTTP/1.1\r\n' + uheaders.join('') + 'Connection: close\r\n\r\n' +
@ -377,7 +377,7 @@ fn (req &Request) build_request_cookies_header() string {
}
mut cookie := []string{}
for key, val in req.cookies {
cookie << '$key: $val'
cookie << '$key=$val'
}
if 'Cookie' in req.headers && req.headers['Cookie'] != '' {
cookie << req.headers['Cookie']