http://www.perlmonks.org?node_id=786539

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

Monks,

I'm trying to access content identified as follows from an LWP POST:
    Content-Type: application/force-download
    Content-Disposition: attachment; filename= Results.txt
`$mess->content' returns nothing.
$mess = $ua->post('https://foobarbaz.com/servlet', Content_Type => 'form-data', Content => [ foo => 'a', bar => 'b', baz => 'c', attachment => [ undef, 'attachment', Content => $req ], ] );
What's the proper way to access the `application/force-download' content?

Much obliged!

Replies are listed 'Best First'.
Re: HTTP::Message vs Content-Type: application/force-download
by ikegami (Patriarch) on Aug 12, 2009 at 15:04 UTC
    application/octet-stream is the official type. application/force-download is not recognised by the browser, which means it gets treated as application/octet-stream. Might as well use application/octet-stream directly.
Re: HTTP::Message vs Content-Type: application/force-download
by Anonymous Monk on Aug 06, 2009 at 21:28 UTC
    `$mess->content' returns nothing.

    What does it contain?

    print $mess->dump;

    What's the proper way to access the `application/force-download' content?

    There is nothing special about application/force- download, simply follow SOP, do it in a browser, then try to replicate the headers (livehttpheaders).

      $mess->dump reports `(no content)'.

      Using cURL:
      HTTP/1.1 100 Continue
      
      HTTP/1.1 200 OK
      Date: Mon, 10 Aug 2009 13:37:02 GMT
      Server: Microsoft-IIS/6.0
      X-Powered-By: ASP.NET
      Server: WebSphere Application Server/6.0
      Content-Type: application/force-download
      Content-Disposition: attachment; filename= Results.txt
      Content-Length: 586
      Content-Language: en-US
      
      Expected Content Here...
      
      Using LWP:
      HTTP/1.1 200 OK
      Connection: close
      Date: Mon, 10 Aug 2009 13:39:02 GMT
      Server: Microsoft-IIS/6.0
      Server: WebSphere Application Server/6.0
      Content-Language: en-US
      X-Powered-By: ASP.NET
      
      (no content)
      
        It has to output a bit more than that
        $ua->add_handler("request_send", sub { shift->dump; return }); $ua->add_handler("response_done", sub { shift->dump; return });