CGI(至少在最近的版本中)會錯誤地編碼x-www-form-urlencoded
參數到一個名爲keywords
的參數中。不如儘管發送適當的內容類型,那麼POSTDATA作品完全一樣的文檔說:
如果發佈的數據類型爲應用程序的不/ X WWW的形式,進行了urlencoded或 的multipart/form-data的,然後在發佈的數據將不會被處理......
use strictures;
use CGI::Emulate::PSGI;
use Plack::Test;
use HTTP::Request::Common;
use Test::More;
my $post = POST "/non-e-importa",
"Content-Length" => 5,
"Content-Type" => "application/x-www-form-urlencoded",
Content => "ohai\n";
my $cgis = CGI::Emulate::PSGI->handler(sub {
use CGI "param", "header";
my $incorrectly_encoded_body = param("keywords");
print header("text/plain"), $incorrectly_encoded_body;
});
test_psgi $cgis, sub {
my $cb = shift;
my $res = $cb->($post);
is $res->content, "ohai", "Soopersek437 param: keywords";
};
done_testing();
__END__
prove so-16846138 -v
ok 1 - Soopersek437 param: keywords
1..1
ok
All tests successful.
Result: PASS
你檢查過'CGI'文檔嗎? – muhmuhten
這是一個格式不正確的請求。數據不是'application/x-www-form-urlencoded'格式。 – ikegami
它如何變形?字母數字字符顯示爲它們自己,非字母數字是它們的ASCII代碼的十六進制表示,對嗎?它是否畸形,因爲它不像param = value這樣的一對? – GL2014