Aquilae has asked for the wisdom of the Perl Monks concerning the following question:
Greetings Monks.
I am trying to create an HTTP request to an ordinary jpg on a website and return and print it.
Instead of an image, I am seeing what appears to be binary data. I have scoured various online websites to try and remedy this. I figured maybe it's a header issue, or perhaps I need to decode or otherwise modify the binary to some viewable format, but all has been to no avail.
Here is the code:
#!perl use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $server_endpoint = "http://upload.wikimedia.org/wikipedia/en/7/70/B +logscope-logo-simple.jpg"; my $req = HTTP::Request->new(GET => $server_endpoint); $req->header('content-type' => 'image/jpeg'); my $resp = $ua->request($req); if ($resp->is_success) { my $message = $resp->content; print $message; }
I appreciate your time and help with this matter! Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Difficulty with using LWP to display JPEG
by roboticus (Chancellor) on Apr 11, 2014 at 18:20 UTC | |
by Aquilae (Novice) on Apr 11, 2014 at 18:26 UTC | |
by roboticus (Chancellor) on Apr 11, 2014 at 18:33 UTC | |
by Aquilae (Novice) on Apr 11, 2014 at 19:03 UTC | |
by roboticus (Chancellor) on Apr 11, 2014 at 19:14 UTC | |
| |
by ww (Archbishop) on Apr 12, 2014 at 17:57 UTC | |
by trwww (Priest) on Apr 12, 2014 at 16:57 UTC |