mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
builtin: str.last_index(); pref: hide-auto-str;
This commit is contained in:
parent
85533fe178
commit
acf0107493
13 changed files with 82 additions and 49 deletions
|
@ -25,3 +25,17 @@ pub fn download_file(url string, out_file_path string) ! {
|
|||
// type DownloadChunkFn = fn (written int)
|
||||
// type DownloadFinishedFn = fn ()
|
||||
// pub fn download_file_with_progress(url string, out_file_path string, cb_chunk DownloadChunkFn, cb_finished DownloadFinishedFn)
|
||||
|
||||
pub fn download_file_with_cookies(url string, out_file_path string, cookies map[string]string) ! {
|
||||
$if debug_http ? {
|
||||
println('http.download_file url=${url} out_file_path=${out_file_path}')
|
||||
}
|
||||
s := fetch(method: .get, url: url, cookies: cookies) or { return err }
|
||||
if s.status() != .ok {
|
||||
return error('received http code ${s.status_code}')
|
||||
}
|
||||
$if debug_http ? {
|
||||
println('http.download_file saving ${s.body.len} bytes')
|
||||
}
|
||||
os.write_file(out_file_path, s.body)!
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue