Subject: | Using LWP::Simple is inefficient. |
The uri() method performs a head() request then a body() request,
meaning that two HTTP requests are performed, thus two TCP connections
need to be opened and torn down in sequence. This wastes network
resources and time.
If you used LWP::UserAgent instead of LWP::Simple you could just do one
request:
$response = LWP::UserAgent->new->get($uri);
Then you can check whether the response was a success (i.e. HTTP 200)
with:
$response->is_success
and you can get the response body like this:
$response->decoded_content
You may also be interested in checking:
$response->headers->content_is_html