in reply to curl http post using LWP::Curl

If the -d @test.xml command is supposed to read the file test.xml into memory and send it as the body of the POST request, I guess you'll have to do the part of reading the file in Perl.

my $filename = 'test.xml'; open my $fh, '<', $filename or die "Couldn't read '$filename': $!"; binmode $fh, ':raw'; my $content = do { local $/; <$fh> }; # sluuurp $hash_form = { ... data => $content ... }

Replies are listed 'Best First'.
Re^2: curl http post using LWP::Curl
by wanderedinn (Sexton) on Jun 07, 2016 at 16:31 UTC

    I thought about that approach. As a short cut I did this:

    my $content = "<test>test</test>"; $hash_form = { data => $content ...

    Still does not push the content to the host properly.

      Have you tried debugging it? What does get sent?

      When dealing with HTTP (well, any kind of TCP) problems, usually Wireshark or tcpdump can tell you what exactly goes over the wire. Usually that's a first hint as to what goes wrong where.

      Note that your seeming addition of headers is not supported by the documentation in Net::Curl.

        Not my box, so I can't use wireshark or tcpdump. Odd that Net::Curl doesn't support headers and does not complain. I think maybe I shouldn't be providing form data at all. It's not a form. I'll research this a bit more.