1

I am sending a PERL POST Request over HTTPS. During sending the request i need to send two things in content one is an authorization token and other is the command need to be executed on the server side.

What should be the approach to send these two things as the content?

Should it be:-

$request->content($token) 
$request->content($command)

OR should it be

my @content =($token,$command) 
$request->content(\@content)

The module which i am using is LWP::UserAgent and in that i will be creating a HTTP::Request type object my $request = HTTP::Request->new(POST => "<url>"); and in this object i am sending content.

shivams
  • 2,597
  • 6
  • 25
  • 47
  • 1
    I think a bit more context is needed - what modules are you using to send (and receive) the POSTed data? – Sobrique Nov 19 '14 at 11:47
  • sorry i forget to give module details. Edited my question above. :) – shivams Nov 19 '14 at 11:52
  • Does this answer your question? [How to POST content with an HTTP Request (Perl)](https://stackoverflow.com/questions/11264470/how-to-post-content-with-an-http-request-perl) – FantomX1 Mar 16 '21 at 09:30

1 Answers1

1

There is only a single content (request body) for a POST request. So any call of content just replaces the previously defined content. Please have a look at the documentation for LWP::UserAgent::post which clearly defines how to send POST data with multiple values. Also, it might be useful if you understand how forms in HTML work, both on the client (browser) and on the server side. Because only if you know what the server side expects in detail you can create the proper request.

Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172