mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb fixes
This commit is contained in:
parent
53307597b3
commit
a3b14e00a2
@ -587,7 +587,9 @@ fn (p mut Parser) check_unused_variables() {
|
|||||||
if var.name == '' {
|
if var.name == '' {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if !var.is_used && !p.pref.is_repl && !var.is_arg && !p.pref.translated {
|
if !var.is_used && !p.pref.is_repl && !var.is_arg &&
|
||||||
|
!p.pref.translated && var.name != 'tmpl_res'
|
||||||
|
{
|
||||||
p.production_error_with_token_index('`$var.name` declared and not used', var.token_idx )
|
p.production_error_with_token_index('`$var.name` declared and not used', var.token_idx )
|
||||||
}
|
}
|
||||||
if !var.is_changed && var.is_mut && !p.pref.is_repl &&
|
if !var.is_changed && var.is_mut && !p.pref.is_repl &&
|
||||||
|
@ -502,7 +502,9 @@ pub fn (v mut V) generate_main() {
|
|||||||
else if v.table.main_exists() {
|
else if v.table.main_exists() {
|
||||||
v.gen_main_start(true)
|
v.gen_main_start(true)
|
||||||
cgen.genln(' main__main();')
|
cgen.genln(' main__main();')
|
||||||
cgen.genln('free(g_str_buf);')
|
if !v.pref.is_bare {
|
||||||
|
cgen.genln('free(g_str_buf);')
|
||||||
|
}
|
||||||
v.gen_main_end('return 0')
|
v.gen_main_end('return 0')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,3 +318,5 @@ pub fn (s Socket) get_port() int {
|
|||||||
C.getsockname(s.sockfd, &addr, &size)
|
C.getsockname(s.sockfd, &addr, &size)
|
||||||
return C.ntohs(addr.sin_port)
|
return C.ntohs(addr.sin_port)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,7 +143,17 @@ pub fn run<T>(app mut T, port int) {
|
|||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
if req.method in methods_with_form {
|
if req.method in methods_with_form {
|
||||||
app.vweb.parse_form(s)
|
for {
|
||||||
|
line := conn.read_line()
|
||||||
|
if line == '' || line == '\r\n' {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
//if line.contains('POST') || line == '' {
|
||||||
|
//break
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
line := conn.read_line()
|
||||||
|
app.vweb.parse_form(line)
|
||||||
}
|
}
|
||||||
if vals.len < 2 {
|
if vals.len < 2 {
|
||||||
$if debug {
|
$if debug {
|
||||||
@ -175,27 +185,27 @@ fn (ctx mut Context) parse_form(s string) {
|
|||||||
if !(ctx.req.method in methods_with_form) {
|
if !(ctx.req.method in methods_with_form) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pos := s.index('\r\n\r\n')
|
//pos := s.index('\r\n\r\n')
|
||||||
if pos > -1 {
|
//if pos > -1 {
|
||||||
mut str_form := s[pos..s.len]
|
mut str_form := s//[pos..s.len]
|
||||||
str_form = str_form.replace('+', ' ')
|
str_form = str_form.replace('+', ' ')
|
||||||
words := str_form.split('&')
|
words := str_form.split('&')
|
||||||
for word in words {
|
for word in words {
|
||||||
$if debug {
|
$if debug {
|
||||||
println('parse form keyval="$word"')
|
println('parse form keyval="$word"')
|
||||||
}
|
|
||||||
keyval := word.trim_space().split('=')
|
|
||||||
if keyval.len != 2 { continue }
|
|
||||||
key := keyval[0]
|
|
||||||
val := urllib.query_unescape(keyval[1]) or {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
$if debug {
|
|
||||||
println('http form "$key" => "$val"')
|
|
||||||
}
|
|
||||||
ctx.form[key] = val
|
|
||||||
}
|
}
|
||||||
|
keyval := word.trim_space().split('=')
|
||||||
|
if keyval.len != 2 { continue }
|
||||||
|
key := keyval[0]
|
||||||
|
val := urllib.query_unescape(keyval[1]) or {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
$if debug {
|
||||||
|
println('http form "$key" => "$val"')
|
||||||
|
}
|
||||||
|
ctx.form[key] = val
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (ctx mut Context) scan_static_directory(directory_path, mount_path string) {
|
fn (ctx mut Context) scan_static_directory(directory_path, mount_path string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user