net: return error unless response code was 200 (#10499)

pull/10500/head
JalonSolov 2021-06-17 18:28:40 -04:00 committed by GitHub
parent 4688c75389
commit 64f34f6d61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -10,6 +10,9 @@ pub fn download_file(url string, out string) ? {
println('download file url=$url out=$out')
}
s := get(url) or { return err }
if s.status_code != 200 {
return error('received http code $s.status_code')
}
os.write_file(out, s.text) ?
// download_file_with_progress(url, out, empty, empty)
}