我无法获得以下Mojo::UserAgent
将 JSON 发布到服务器的调用:
use Mojo::UserAgent;
my $ua=Mojo::UserAgent->new;
my $json = $ua->post("localhost:6767" => {} => json =>{ val=>10 })->res->json;
在另一端使用假调试服务器nc -l 6767
会给出以下输出:
POST / HTTP/1.1
User-Agent: Mojolicious (Perl)
Connection: keep-alive
Content-Length: 0
Host: localhost:6767
不仅仅是json
方法,form
整个 Transactor 似乎在我的两台机器上都坏了。从文档:
perl -MMojo::UserAgent::Transactor -E 'say Mojo::UserAgent::Transactor->new->tx(PUT => "http://kraih.com" => json => {a => "b"})->req->to_string;'
PUT / HTTP/1.1
Content-Length: 4
Host: kraih.com
json
很难相信我的眼睛。我错过了什么?