http: fix cookies

pull/5990/head^2
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']

View File

@ -24,7 +24,7 @@ mut:
pub mut:
module_search_paths []string
parsed_files []ast.File
cached_msvc MsvcResult
cached_msvc MsvcResult
table &table.Table
}
@ -42,7 +42,9 @@ pub fn new_builder(pref &pref.Preferences) Builder {
if pref.ccompiler == 'msvc' {
verror('Cannot find MSVC on this OS')
}
MsvcResult { valid: false }
MsvcResult{
valid: false
}
}
return Builder{
pref: pref
@ -65,9 +67,14 @@ pub fn new_builder(pref &pref.Preferences) Builder {
// parse all deps from already parsed files
pub fn (mut b Builder) parse_imports() {
mut done_imports := []string{}
if b.pref.is_script {
done_imports << 'os'
if b.pref.is_script {
done_imports << 'os'
}
for file in b.parsed_files {
if file.mod.name != 'main' && file.mod.name !in done_imports {
done_imports << file.mod.name
}
}
// NB: b.parsed_files is appended in the loop,
// so we can not use the shorter `for in` form.
for i := 0; i < b.parsed_files.len; i++ {
@ -244,7 +251,9 @@ fn (b &Builder) show_total_warns_and_errors_stats() {
}
fn (b &Builder) print_warnings_and_errors() {
defer { b.show_total_warns_and_errors_stats() }
defer {
b.show_total_warns_and_errors_stats()
}
if b.pref.output_mode == .silent {
if b.checker.nr_errors > 0 {
exit(1)