gpt4 book ai didi

perl - 如何在包含 application/x-www-form-urlencoded 数据的 perl 中发出 HTTP PUT 请求?

转载 作者:可可西里 更新时间:2023-11-01 15:26:57 29 4
gpt4 key购买 nike

如何在 Perl 中发出包含 application/x-www-form-urlencoded 数据的 HTTP PUT 请求?

这是一个有效的等效 POST 请求:

my $ua       = new LWP::UserAgent;
my $response = $ua->post(
$url,
{
"parameter1" => $value1,
"parameter2" => $value2
}
);

如何将其作为 PUT 请求完成?LWP 和 PUT function in HTTP::Request::Common 中没有 put 方法不采用表单数据。

有关是否允许带有表单数据的 PUT 请求的讨论,请参阅 Can HTTP PUT request have application/x-www-form-urlencoded as the Content-Type?

这是一个 PUT 请求的示例,但它不包含包含表单数据的代码:How to make a HTTP PUT request using LWP?

最佳答案

只需制作POST-请求并将其方法更改为PUT:

use HTTP::Request::Common;

my $req = POST('http://example.com/', Content => [param => 'value']);

$req->method('PUT');

say($req->as_string);

关于perl - 如何在包含 application/x-www-form-urlencoded 数据的 perl 中发出 HTTP PUT 请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11202123/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com