How do I open the attachment txt file from server response using perl?

406 views Asked by At

sorry if, this question seems simple, but I have been searching for a while now and have not found an answer that can be applied to my situation.

I wrote a little perl script that uploads a file to a server. This server responds with a:

HTTP/1.1 200 OK

It wasn't until I read the response as string:

print $res->as_string, "\n";

that I saw that the server seemed to have attached his response in a file:

Content-Disposition: attachment; filename=filename.txt

How do I get to the content of this .txt file using perl?

1

There are 1 answers

3
nwellnhof On BEST ANSWER

The Content-Disposition header in the HTTP response is mainly a hint for browsers to save the file as download named filename.txt. You can access the file just like the content of every other HTTP response:

$res->content

or

$res->decoded_content

I assume you use LWP::UserAgent.