From 64f34f6d612eab50a5a4e3ad09ae4e9c4596f1e0 Mon Sep 17 00:00:00 2001 From: JalonSolov Date: Thu, 17 Jun 2021 18:28:40 -0400 Subject: [PATCH] net: return error unless response code was 200 (#10499) --- vlib/net/http/download.v | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vlib/net/http/download.v b/vlib/net/http/download.v index 51c216cab5..18cf585ae0 100644 --- a/vlib/net/http/download.v +++ b/vlib/net/http/download.v @@ -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) }