Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » Detect connection, valid URL, 404 page
Detect connection, valid URL, 404 page [message #14268] Thu, 21 February 2008 12:24 Go to next message
Engeor is currently offline  Engeor
Messages: 12
Registered: January 2008
Promising Member
If I try to load a file that does not exists on the server then the http server returns 404 page. In this case HttpClient returns no error so I search returned buffer for 404 inside <TITLE> tag.

1) Is there any better way how to detect that file does not exists on the server?
2) How to detect non-existing server? (Another way that wait for timeout).

Engeor
Re: Detect connection, valid URL, 404 page [message #14294 is a reply to message #14268] Thu, 21 February 2008 20:20 Go to previous messageGo to next message
Engeor is currently offline  Engeor
Messages: 12
Registered: January 2008
Promising Member
I didn't realized that the content of the file that is returned by server in case that the desired file wasn't found is not defined. This is why searching for 404 is not good idea. Now I look into header for "Last-Modified" because dynamically generated files haven't this line in header. Generally, it is not optimal as well but it suits my need because I download only static files.
Re: Detect connection, valid URL, 404 page [message #14301 is a reply to message #14268] Thu, 21 February 2008 22:58 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 697
Registered: December 2005
Location: Budapest, Hungary
Contributor
Engeor wrote on Thu, 21 February 2008 12:24

If I try to load a file that does not exists on the server then the http server returns 404 page. In this case HttpClient returns no error so I search returned buffer for 404 inside <TITLE> tag.

1) Is there any better way how to detect that file does not exists on the server?

Use GetStatusCode() to get HTTP status code.
Quote:


2) How to detect non-existing server? (Another way that wait for timeout).



On timeout, the result will be an empty string and you can use IsError() as well.
You can get error message calling GetError().
Re: Detect connection, valid URL, 404 page [message #14499 is a reply to message #14268] Wed, 27 February 2008 15:32 Go to previous message
Engeor is currently offline  Engeor
Messages: 12
Registered: January 2008
Promising Member
Thank you. Is there any faster way? Timeout block program for long time.
Previous Topic: Checking socket connection after send.
Next Topic: CPU_Cores() error
Goto Forum:
  


Current Time: Wed Apr 24 16:10:19 CEST 2024

Total time taken to generate the page: 0.03282 seconds