Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: curl http post using LWP::Curl

by Corion (Patriarch)
on Jun 07, 2016 at 16:25 UTC ( [id://1165090]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-24 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found