1. Daniel Seguin
  2. PowerBuilder
  3. Tuesday, 20 August 2024 22:50 PM UTC
Hello,

I am using Powerbuilder 2022R3 - 3356 On my personal development box, the command li_status = wb_navigator.Navigate("www.google.ca") returns 1 (valid url) li_status = wb_navigator.Navigate("something") returns -1 (it's not a valid url) but on my client box, with the same version the example with the invalid url still returns 1 here is a snippet of the code: =================================================================================================================================

//actual web url to navigate to
is_url_orig = ls_url

//test the webbrowser error management
//something is not a valid url so it should return a value < 0, i would expect -5
//but when testing in a different dev environment (mine), it returns -1
//on the client machine, powerbuilder returns a 1 thinking something is a valid website
ls_url = "something"

// SPRF-1589, 2024-08-19, D.Seguin - Utilisation du nouveau standard visual webbrowser alias u_webbrowser
li_status = wb_navigateur.Navigate(ls_url) 
if li_status <> 1 then
	ls_msgerreur = "Une erreur est apparue lors de l'ouverture de la page internet suivante: " + & 
	trim(ls_url) + "~r~n"
	choose case li_status
	   case -1
			ls_msgerreur = trim(ls_msgerreur) + "Erreur général"
	   case -2 
			ls_msgerreur = trim(ls_msgerreur) + "Erreur causée par l'impossibilité d'obtenir un instance du navigateur"
	   case -5
			ls_msgerreur = trim(ls_msgerreur) + "Erreur causée par une adresse internet invalide"
	end choose
	SignalError (15000, ls_msgerreur)
end if
=================================================================================================================================

Any ideas?

Thanks Daniel

 

Accepted Answer
Daniel Seguin Accepted Answer Pending Moderation
  1. Friday, 23 August 2024 01:05 AM UTC
  2. PowerBuilder
  3. # Permalink

Hello,

I have developed a work around solution to validate the URL before passing it to the navigate method of the webrowser:

Here is a sample function.

I used the Powerbuilder http client to validate the header of the website.

Powerbuilder was working fine but there appeared to be something on the client site, altering the PB's reaction

So in those type of cases, we can use this function to do a URL validation before initiating the navigate method.

gf_validateUrl(string as_url) returning lb_ok 

 

boolean lb_valid
integer li_response = -1
integer li_rc
string ls_content_length
string ls_url
integer li_pos

li_pos = pos(as_url, upper("c:"), 1 )

if li_pos > 0 then

   if FileExists(as_url) then
      lb_valid = true
   else
      lb_valid = false
   end if

else

   // S'assurer que le URL commence par http ou https
   if Lower(Left(as_url, 4)) <> 'http' then as_url = 'https://' + trim(as_url)

   HttpClient lo_httpclient
   lo_httpclient = Create HttpClient

   // si le serveur ne supporte pas HEAD, vous pouvez utiliser GET
   li_rc = lo_httpclient.SendRequest('HEAD', as_url)

   if li_rc = 1 then

      li_response = lo_httpclient.GetResponseStatusCode()

      choose case li_response
         case 200
            // page trouvée
            lb_valid = true
         case 404
            // page non trouvée
             lb_valid = false
         case 401
            // la page est trouvée mais l'utilisateur 
            // n'est pas authorisé pour y acceder
            lb_valid = true
         case else
            // autres erreurs
            lb_valid = false
      end choose

   else
 
      // le send request HEAD a pas reussi a cause d'un erreur de serveur
      // au besoins on pourrait logger la variable li_rc avec le URL en question as_url
      lb_valid = false

   end if

   destroy lo_httpclient

end if

return lb_valid 

 

 

Comment
  1. Daniel Seguin
  2. Friday, 23 August 2024 02:10 AM UTC
Thanks!

With pleasure!
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 23 August 2024 08:21 AM UTC
"li_pos = pos(as_url, upper("c:"), 1 )"

What if the file is not on the C: drive but on the D: drive?
  1. Helpful 1
  1. Miguel Leeuwe
  2. Friday, 23 August 2024 08:22 AM UTC
Or on a mapped network drive?

regards
  1. Helpful 1
There are no comments made yet.
Daniel Seguin Accepted Answer Pending Moderation
  1. Wednesday, 21 August 2024 11:27 AM UTC
  2. PowerBuilder
  3. # 1

When testing my code on PB2019, I still get 1 for an invalid url.

but the webbrowser gets a response from the web instance to say website is not valid 

  
 
Could this be an issue on my cilent's side how websites are resolved?
 
Windows 10 returns this message
Windows 11 returns nothing
 
 
Comment
  1. Andreas Mykonios
  2. Wednesday, 21 August 2024 11:51 AM UTC
What version of PB 2019 have you checked? PB 2019 was using a different web browser engine! Only PB 2019 R3 build 2797 and later uses that same web browser control as PB 2022 R3. So depending on the exact version build you tested in PB 2019, the different behaviour may be reasonable.

Andreas.
  1. Helpful 1
  1. Daniel Seguin
  2. Wednesday, 21 August 2024 12:05 PM UTC
I have version PB 2019R32728

  1. Helpful
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 21 August 2024 06:11 AM UTC
  2. PowerBuilder
  3. # 2

Hi.

Checked your code and in my pc I get -1... Don't know why in your client's pc you get a different result. I wonder if there are any specific settings that cause a different behavior.

Andreas.

Comment
  1. Daniel Seguin
  2. Wednesday, 21 August 2024 10:52 AM UTC
Thanks for checking my code and getting and getting a -1 when url is not valid and 1 if it's valid.

Maybe the setting issue is on their internet navigation on windows 11 since we have migrated to PB2022R3 on Win11.

I will try my code in PB2019 on Win10 to see the results there.

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.