This commit is contained in:
garnier-quentin 2020-06-05 09:45:29 +02:00
parent 256e7ec067
commit fcac48977b
3 changed files with 7 additions and 3 deletions

View File

@ -148,7 +148,8 @@ sub load_request {
$self->{options_request} = {}; $self->{options_request} = {};
if (defined($self->{option_results}->{data}) && $self->{option_results}->{data} ne '') { if (defined($self->{option_results}->{data}) && $self->{option_results}->{data} ne '') {
$self->{option_results}->{method} = 'POST'; $self->{option_results}->{method} = defined($self->{option_results}->{method}) && $self->{option_results}->{method} ne '' ?
$self->{option_results}->{method} : 'POST';
if (-f $self->{option_results}->{data} and -r $self->{option_results}->{data}) { if (-f $self->{option_results}->{data} and -r $self->{option_results}->{data}) {
local $/ = undef; local $/ = undef;
my $fh; my $fh;

View File

@ -180,6 +180,9 @@ sub set_method {
if ($options{request}->{method} eq 'DELETE') { if ($options{request}->{method} eq 'DELETE') {
$self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_CUSTOMREQUEST'), parameter => $options{request}->{method}); $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_CUSTOMREQUEST'), parameter => $options{request}->{method});
} }
if ($options{request}->{method} eq 'PATCH') {
$self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_CUSTOMREQUEST'), parameter => $options{request}->{method});
}
} }
sub set_auth { sub set_auth {

View File

@ -166,7 +166,7 @@ sub request {
if (defined($request_options->{no_follow})) { if (defined($request_options->{no_follow})) {
$self->{ua}->requests_redirectable(undef); $self->{ua}->requests_redirectable(undef);
} else { } else {
$self->{ua}->requests_redirectable([ 'GET', 'HEAD', 'POST' ]); $self->{ua}->requests_redirectable([ 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'PATCH' ]);
} }
if (defined($request_options->{http_peer_addr})) { if (defined($request_options->{http_peer_addr})) {
push @LWP::Protocol::http::EXTRA_SOCK_OPTS, PeerAddr => $request_options->{http_peer_addr}; push @LWP::Protocol::http::EXTRA_SOCK_OPTS, PeerAddr => $request_options->{http_peer_addr};
@ -196,7 +196,7 @@ sub request {
} }
} }
if ($request_options->{method} eq 'POST') { if ($request_options->{method} ne 'GET') {
if (defined($content_type_forced)) { if (defined($content_type_forced)) {
$req->content_type($content_type_forced); $req->content_type($content_type_forced);
$req->content($request_options->{query_form_post}); $req->content($request_options->{query_form_post});