request assistance resolving a std.net.curl segmentation fault
kdevel
kdevel at vogtner.de
Sat May 20 09:20:54 UTC 2023
On Friday, 19 May 2023 at 23:36:28 UTC, anonymouse wrote:
> [...]
> The reason I used a while loop was to detect loss of internet
> connection and resume the process once the connection is
> re-established.
What if the internet connection is not re-established within an
reasonable amount of time? What if the resource is no longer
available on the server (HTTP eror 404 [1])? If there is an
interactive user: Wouldn't it be better have the user restart the
download at his discretion?
> What would have been a better approach?
That depends on where you want to use that download function. If
it is intended to download a full software update of a modern
e-vehicle I would suggest not to use such an endless loop. I
would limit the retries to a low single-digit number greater than
one and of log the event.
[1] The 404 or other errors are not detected by default.
```
curl.set(CurlOption.failonerror, 1);
```
must be set. In case of error an exception is thrown. This
unfortunately does not contain the required error information. It
seems that one must supply an error buffer
```
ubyte [<?>] buf;
curl.set (CurlOption.errorbuffer, buf.ptr);
```
to store that result.
More information about the Digitalmars-d-learn
mailing list