From cf4235ab65a1dc3541a380d9c281a5256561d8a6 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 26 Jul 2020 15:54:18 +0200 Subject: [PATCH] http: fix cookies --- vlib/net/http/backend_nix.c.v | 1 + vlib/net/http/http.v | 6 +++--- vlib/v/builder/builder.v | 19 ++++++++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/vlib/net/http/backend_nix.c.v b/vlib/net/http/backend_nix.c.v index 738ee5d9d9..a76f1c7a17 100644 --- a/vlib/net/http/backend_nix.c.v +++ b/vlib/net/http/backend_nix.c.v @@ -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 diff --git a/vlib/net/http/http.v b/vlib/net/http/http.v index c63ffb25a4..984a3ad3fe 100644 --- a/vlib/net/http/http.v +++ b/vlib/net/http/http.v @@ -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'] diff --git a/vlib/v/builder/builder.v b/vlib/v/builder/builder.v index 8b4128d114..e6649a22f0 100644 --- a/vlib/v/builder/builder.v +++ b/vlib/v/builder/builder.v @@ -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)