builtin: str.last_index(); pref: hide-auto-str;

This commit is contained in:
Alexander Medvednikov 2024-03-28 18:26:30 +03:00
parent 85533fe178
commit acf0107493
13 changed files with 82 additions and 49 deletions

View file

@ -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)!
}