[fpc-devel] Avoid exception if FPHTTPClient cannot connect to server?
    Michael Van Canneyt 
    michael at freepascal.org
       
    Mon Jul 31 14:37:57 CEST 2017
    
    
  
On Mon, 31 Jul 2017, Werner Pamler wrote:
> Here is a little demo program which uses fphttpclient to download some 
> file from some server.
>
> If the URL exists everything is fine (note on Windows, that the OpenSSL 
> dlls must be copied to the exe directory for the demo to work). If the 
> URL does not exist, but the server responds, the program returns the 
> well-known error 404 (if the 404 has been added to the response codes in 
> HTTPMethod) - also fine. But if a connection to the server cannot be 
> established -- maybe because the server URL is wrong -- then the program 
> creates an exception. Synapse, on the other hand, does not crash on this 
> occasion, it just returns an error 500. This behavior appears to be much 
> more consistent than fpc's.
>
> Is this intentional? Or should I report a bug?
This is very intentional.
Returning a 500 on connection error is plain wrong. 
Status 500 indicates an internal error on the server. 
This is an 'agreement' governed by a RFC.
But if the connection cannot be made, there was no server, 
and there cannot be a server status either.
Michael.
    
    
More information about the fpc-devel
mailing list