[Issue 18318] std.net.curl.download silently ignores non-2xx http statuses
https://issues.dlang.org/show_bug.cgi?id=18318 Iain Buclaw changed: What|Removed |Added Priority|P5 |P2 --
[Issue 18318] std.net.curl.download silently ignores non-2xx http statuses
https://issues.dlang.org/show_bug.cgi?id=18318 --- Comment #7 from Dlang Bot --- dlang/dmd pull request #10590 "build.d: Make download fail reliably" was merged into master: - 78e079b28027972b6cac862e81efd2f968b6f07c by MoonlightSentinel: build.d: Make download fail reliably `download` would sometimes return true on failure (caused by Issue 18318 which requires additional work in dub). This commit implements a temporary workaround and should be reverted when the issue is resolved. See https://issues.dlang.org/show_bug.cgi?id=18318 https://github.com/dlang/dmd/pull/10590 --
[Issue 18318] std.net.curl.download silently ignores non-2xx http statuses
https://issues.dlang.org/show_bug.cgi?id=18318 --- Comment #6 from Dlang Bot --- @MoonlightSentinel created dlang/dmd pull request #10590 "build.d: Make download fail reliably" mentioning this issue: - build.d: Make download fail reliably `download` would sometimes return true on failure (caused by Issue 18318 which requires additional work in dub). This commit implements a temporary workaround and should be reverted when the issue is resolved. See https://issues.dlang.org/show_bug.cgi?id=18318 https://github.com/dlang/dmd/pull/10590 --
[Issue 18318] std.net.curl.download silently ignores non-2xx http statuses
https://issues.dlang.org/show_bug.cgi?id=18318 --- Comment #5 from Dlang Bot --- @MartinNowak updated dlang/phobos pull request #6102 "fix Issue 18318 - std.net.curl.download silently ignores non-2xx..." fixing this issue: - fix Issue 18318 - std.net.curl.download silently ignores non-2xx... ...http statuses - check status code of server response and throw HTTPStatusException - still downloads the page if intended - not using CURLOPT_FAILONERROR in the low-level API, as that has would be too disruptive, and comes with many catches itself i.e. only the high-level get/post/.../download/upload throw HTTPStatusExceptions https://github.com/dlang/phobos/pull/6102 --
[Issue 18318] std.net.curl.download silently ignores non-2xx http statuses
https://issues.dlang.org/show_bug.cgi?id=18318 --- Comment #4 from Martin Nowak --- (In reply to Aravinda from comment #2) > auto conn = HTTP(url); > download(url, "tmp", conn); > auto status = conn.statusLine(); > if (status.code == 200){ Thanks, that's a helpful workaround for the time being. But by default, high-level functions should throw on errors, so that they aren't accidentally ignored. --
[Issue 18318] std.net.curl.download silently ignores non-2xx http statuses
https://issues.dlang.org/show_bug.cgi?id=18318 Martin Nowak changed: What|Removed |Added Keywords||pull --- Comment #3 from Martin Nowak --- https://github.com/dlang/phobos/pull/6102 --
[Issue 18318] std.net.curl.download silently ignores non-2xx http statuses
https://issues.dlang.org/show_bug.cgi?id=18318 Aravinda changed: What|Removed |Added CC||hallimanearav...@gmail.com --- Comment #2 from Aravinda --- (In reply to Martin Nowak from comment #0) > cat > bug.d << CODE > import std.net.curl; > > void main() > { > // get("dlang.org/non-existent-foobar"); // throws HTTPStatusException > 404 > download("dlang.org/non-existent-foobar", "tmp"); // silently writes 404 > response, with no way to detect the error > } > CODE > > dmd -run bug Below code works with error handling. import std.stdio; import std.net.curl; void main() { auto url = "dlang.org/non-existent-foobar"; auto conn = HTTP(url); download(url, "tmp", conn); auto status = conn.statusLine(); if (status.code == 200){ writeln("Downloaded successfully!"); } else { writefln("Failed to download. Error: %d %s", status.code, status.reason); } } --
[Issue 18318] std.net.curl.download silently ignores non-2xx http statuses
https://issues.dlang.org/show_bug.cgi?id=18318 --- Comment #1 from Martin Nowak --- I does throw a CurlException for things like timeouts, connection-failures, or ssl issues. --