mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2003
Posts: 2,812
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
When requesting an $urlget() with the 'bh' (binvar; HEAD) options, there is no target binvar created within the callback alias, as there is with 'bg' (binvar; GET).
This seems invalid, because $urlget(%id).target will declare a &binvar name, but that binvar does not exist. It causes $bvar(&binvar,1-).text to throw an erroneous error.

I'm of the opinion that the &target binvar should be populated by the header reply when requesting the HEAD method.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
Thanks for your bug report. This is intentional. The HEAD result is only ever returned in $urlget().reply.

Joined: Feb 2003
Posts: 2,812
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Cool beans. So how is the script supposed to know that the &target binvar exists or does not exist, to prevent it from tripping errors?

Authors can either anticipate the existence of the &target binvar, per ($urlget(%id).target == &target), or lose faith in the universe, not both.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
Quote
Cool beans. So how is the script supposed to know that the &target binvar exists or does not exist, to prevent it from tripping errors?

The only method is to use $bvar() to check if it exists. The .target property only tells you what was requested by $urlget(), it does not guarantee that the target file or binvar exists. In my scripts, I use $isfile() and $bvar() to check these.

Joined: Feb 2003
Posts: 2,812
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Ok, so Inline Example:
Code
echo -a $iif($bvar($urlget($1).target),$bvar($v1,1-).text)

Structured Example:
Code
var %id = $1, %binvar = $urlget(%id).target, %target
if ($bvar(%binvar)) {
  var %target = $bvar(%binvar,1-).text
}
echo -a %target


Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Link Copied to Clipboard