Re: curl: catching exception on connect.

2014-12-03 Thread Ali Çehreli via Digitalmars-d-learn
On 12/02/2014 05:19 AM, Suliman wrote: connect() sends a "CONNECT" request to the server, as defined by HTTP [1]. This method is only used when you're working with proxies and the like. What you most likely want, however, is a "GET" request. Use get() for that. So what is the best way to chec

Re: curl: catching exception on connect.

2014-12-02 Thread Suliman via Digitalmars-d-learn
connect() sends a "CONNECT" request to the server, as defined by HTTP [1]. This method is only used when you're working with proxies and the like. What you most likely want, however, is a "GET" request. Use get() for that. So what is the best way to check status server response (400, 404 et

Re: curl: catching exception on connect.

2014-12-02 Thread via Digitalmars-d-learn
On Monday, 1 December 2014 at 19:44:56 UTC, Suliman wrote: My guess is that you have to use HTTPS for CONNECT and that you have to have credentials for it. (?) Ali dlang.org should work on HTTP, but not HTTPS. Also I do not think that when I connect to HTTPS I should have any credentials. I

Re: curl: catching exception on connect.

2014-12-01 Thread Suliman via Digitalmars-d-learn
My guess is that you have to use HTTPS for CONNECT and that you have to have credentials for it. (?) Ali dlang.org should work on HTTP, but not HTTPS. Also I do not think that when I connect to HTTPS I should have any credentials. It's mostly like issue with curl...

Re: curl: catching exception on connect.

2014-12-01 Thread Ali Çehreli via Digitalmars-d-learn
On 12/01/2014 10:25 AM, Suliman wrote: > why: > string link = "dlang.org"; > writeln(connect(link)); > > cause crash: (To be pedantic: An unhandled exception is not a crash. ;) ) > std.net.curl.CurlException@C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\net\curl > > .d(779): HTTP r

Re: curl: catching exception on connect.

2014-12-01 Thread Suliman via Digitalmars-d-learn
Big thanks Ali! Only the small last question: why: string link = "dlang.org"; writeln(connect(link)); cause crash: std.net.curl.CurlException@C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\net\curl .d(779): HTTP request returned status code 400 0x00404263 0x00402

Re: curl: catching exception on connect.

2014-12-01 Thread Ali Çehreli via Digitalmars-d-learn
On 11/30/2014 10:38 PM, Suliman wrote: > Am I right understand all exception are derived from "assertThrown" > http://dlang.org/phobos/std_exception.html No, all exceptions are derived from Throwable. It has two descendants: - Error, representing conditions that are irrecoverable, and - Except

Re: curl: catching exception on connect.

2014-11-30 Thread Meta via Digitalmars-d-learn
On Sunday, 30 November 2014 at 19:24:39 UTC, Suliman wrote: I can't understand why I am getting exception on next code: void downloadFile() { foreach(link; links) { try {

Re: curl: catching exception on connect.

2014-11-30 Thread Suliman via Digitalmars-d-learn
Am I right understand all exception are derived from "assertThrown" http://dlang.org/phobos/std_exception.html So "msg" in "catch(Exception msg)" is from function "assertThrown"? Could you show me example of how to handle type of exception?

Re: curl: catching exception on connect.

2014-11-30 Thread Ali Çehreli via Digitalmars-d-learn
This is turning out to be a common problem. :) On 11/30/2014 11:24 AM, Suliman wrote: > I can't understand why I am getting exception on next code: > > void downloadFile() > { > foreach(link; links) > { > try > { > writeln(con

curl: catching exception on connect.

2014-11-30 Thread Suliman via Digitalmars-d-learn
I can't understand why I am getting exception on next code: void downloadFile() { foreach(link; links) { try { writeln(connect(link)); }