net.http: cookie parsing fixes (#14420)
parent
8027919285
commit
1d462136bc
|
@ -68,10 +68,11 @@ pub fn read_cookies(h map[string][]string, filter string) []&Cookie {
|
||||||
mut line := line_.trim_space()
|
mut line := line_.trim_space()
|
||||||
mut part := ''
|
mut part := ''
|
||||||
for line.len > 0 {
|
for line.len > 0 {
|
||||||
if line.index_any(';') > 0 {
|
mut semicolon_position := line.index_any(';') // Store the position of the next semicolon
|
||||||
line_parts := line.split(';')
|
if semicolon_position > 0 { // So, there is a semicolon, let's parse until that position
|
||||||
|
line_parts := line[..semicolon_position].split(';') // split the line only until that semicolon
|
||||||
|
line = line[(semicolon_position + 1)..] // and then skip everything before the semicolon
|
||||||
part = line_parts[0]
|
part = line_parts[0]
|
||||||
line = line_parts[1]
|
|
||||||
} else {
|
} else {
|
||||||
part = line
|
part = line
|
||||||
line = ''
|
line = ''
|
||||||
|
|
|
@ -214,11 +214,17 @@ pub fn parse_request_head(mut reader io.BufferedReader) ?Request {
|
||||||
}
|
}
|
||||||
header.coerce(canonicalize: true)
|
header.coerce(canonicalize: true)
|
||||||
|
|
||||||
|
mut request_cookies := map[string]string{}
|
||||||
|
for _, cookie in read_cookies(header.data, '') {
|
||||||
|
request_cookies[cookie.name] = cookie.value
|
||||||
|
}
|
||||||
|
|
||||||
return Request{
|
return Request{
|
||||||
method: method
|
method: method
|
||||||
url: target.str()
|
url: target.str()
|
||||||
header: header
|
header: header
|
||||||
version: version
|
version: version
|
||||||
|
cookies: request_cookies
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue