LWP::Simple - relative or absolute path?

J

jwcarlton

I'm having a server issue at the moment that's keeping me from using a
relative path with LWP::Simple. I can use an absolute path with no
problem, though. It's not a big deal; I made several security updates,
and inadvertently changed something that's causing this error.

So, here's the question. Is there a speed/server load difference
between using a relative path or an absolute path? For this purpose,
the absolute path is on the same domain, IP, and server as the script
loading it.

I would normally test it myself, but since I can't load a relative
path right now, I can't test it. I'm hoping that one of you will
already know, before I spend too much time trying to correct a server
issue that may be irrelevant.
 
R

RedGrittyBrick

I'm having a server issue at the moment that's keeping me from using a
relative path with LWP::Simple.

A *relative path*?

Are you using LWP::Simple's get($url) subroutine?

If so, the URL has to fully specify the protocol, server and the full
document path.

I can use an absolute path with no
problem, though. It's not a big deal; I made several security updates,
and inadvertently changed something that's causing this error.

Which error did you have in mind? What is the actual error message?

So, here's the question. Is there a speed/server load difference
between using a relative path or an absolute path? For this purpose,
the absolute path is on the same domain, IP, and server as the script
loading it.

HTTP requests (such as those transmitted by LWP::Simple get($url)) use
fully specified URLs. The returned HTML may contain links that are
relative - in which case a browser following those links would use the
page context to construct a full URL from the relative link.

In other words, I don't understand what you are saying. Maybe you could
elaborate a little and provide some example code and actual output?
 
J

jwcarlton

A *relative path*?
Are you using LWP::Simple's get($url) subroutine?

If so, the URL has to fully specify the protocol, server and the full
document path.

That's correct; I'm just curious which of these would be less of a
server load (if there's a difference at all):

# relative path
$var = get("../whatever.txt");

# or absolute path
$var = get("http://www.example.com/whatever.txt");

Which error did you have in mind? What is the actual error message?

I don't have an error message or anything, and nothing shows up in the
logs; it simply returns an empty variable. Using a relative path (like
above) worked fine until a week or so ago, when I made several
security updates to the server, so I'm guessing that one of those
updates is now preventing the file from opening in this way.

I wasn't actually using LWP::Simple on my existing website, but I'm
making several updates and changes that do use LWP::Simple. I've been
making security updates for about 10 days now, and only just yesterday
discovered that this was no longer working the same as before.

It's not really a big deal, though, and I suspect that I'm making
things better by requiring an absolute path, anyway. I just wanted to
make sure that switching my scripts to absolute paths like this would
be the same load (or preferably, less of a load), or if I should track
down whatever it was that made relative paths stop working in the
first place.
 
P

Peter J. Holzer

That's correct; I'm just curious which of these would be less of a
server load (if there's a difference at all):

The difference is simple:
# relative path
$var = get("../whatever.txt");

This doesn't work.
# or absolute path
$var = get("http://www.example.com/whatever.txt");

This works.

I don't have an error message or anything, and nothing shows up in the
logs; it simply returns an empty variable.

That's why you shouldn't use LWP::Simple for production: It
returns just undef on error and you are left guessing what the error
was.
Using a relative path (like above) worked fine until a week or so ago,

I don't believe that. "../whatever.txt" doesn't contain a server name,
so get wouldn't know which server to connect to.

It is possible that older versions of LWP::Simple returned the contents
of the file if the argument looked like a filename instead of an URI -
in that case the script might have appeared to work but really did
something different than you thought.

hp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,729
Latest member
ScarlettJe

Latest Threads

Top