Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Missing filename header

by Anonymous Monk
on Mar 21, 2019 at 11:16 UTC ( [id://1231532]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
I am trying to download .exe file from the server, I can fetch that file but while running the exe file, I get below error,
"Missing filename header".
below is the code:

use strict; use LWP::Simple; my $url = "http://server:port/ws/1/console/webstart?full=true"; my $file = "Console.exe"; my $code = getstore($url, "$file"); print "CODE : $code\n";
Can you please help me to get rid of this error.
Thanks & Regards.

Replies are listed 'Best First'.
Re: Missing filename header
by Corion (Patriarch) on Mar 21, 2019 at 11:38 UTC

    Have you read LWP::Simple? What filename to you expect the file to be stored in? Where does that filename come from?

    My guess is that if no filename is given by the program, LWP::Simple::getstore will fall back on the Content-Disposition header and the filename supplied there. But the error message suggests that the page is sending no such header.

    My suggestion is that you inspect the headers you get back, and also look at the content that is returned by that URL. If all else fails, why don't you manually supply the filename? You supply the filename, so are you really, really sure that the code you are running produces the error message you are seeing?

Re: Missing filename header
by hippo (Bishop) on Mar 21, 2019 at 11:48 UTC

      Hi Hippo,
      This GET request does need authentication actually, I can download from the browser and working fine when downloaded from the browser.
      Thanks.

Re: Missing filename header
by Corion (Patriarch) on Mar 21, 2019 at 11:36 UTC

    Have you read LWP::Simple? What filename to you expect the file to be stored in? Where does that filename come from?

    My guess is that if no filename is given by the program, LWP::Simple::getstore will fall back on the Content-Disposition header and the filename supplied there. But the error message suggests that the page is sending no such header.

    My suggestion is that you inspect the headers you get back, and also look at the content that is returned by that URL. If all else fails, why don't you manually supply the filename?

      I also tried with below, but it doesn't seem to be working.

      print "Content-Type:application/vnd.microsoft.portable-executable\n"; print "Content-Disposition:attachment;filename='BCM_console.exe'\n\n";
      HI Corion,

      I have given that filename as I wanted to store it by that name.

      I checked with the head($url) method of LWP::useragent, which returns nothing.

      why don't you manually supply the filename?
      Can you tell me, how do we do that.

      Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1231532]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-24 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found