Fix httplib problems
This commit is contained in:
parent
d5c7f888f2
commit
c479448c2c
|
@ -144,6 +144,7 @@ sub check_options {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$self->{headers}->{SOAPAction} = $self->{option_results}->{service_soap};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub load_request {
|
sub load_request {
|
||||||
|
|
|
@ -82,18 +82,28 @@ sub connect {
|
||||||
}
|
}
|
||||||
$req = HTTP::Request->new($method => $uri);
|
$req = HTTP::Request->new($method => $uri);
|
||||||
|
|
||||||
if ($method eq 'POST') {
|
my $content_type_forced;
|
||||||
my $uri_post = URI->new();
|
|
||||||
if (defined($options{query_form_post})) {
|
|
||||||
$uri->query_form($options{query_form_post});
|
|
||||||
}
|
|
||||||
$req->content_type('application/x-www-form-urlencoded');
|
|
||||||
$req->content($uri_post->query);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined($options{headers})) {
|
if (defined($options{headers})) {
|
||||||
foreach my $key (keys %{$options{headers}}) {
|
foreach my $key (keys %{$options{headers}}) {
|
||||||
$req->header($key => $options{headers}->{$key});
|
if ($key !~ /content-type/i) {
|
||||||
|
$req->header($key => $options{headers}->{$key});
|
||||||
|
} else {
|
||||||
|
$content_type_forced = $options{headers}->{$key};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($method eq 'POST') {
|
||||||
|
if (defined($content_type_forced)) {
|
||||||
|
$req->content_type($content_type_forced);
|
||||||
|
$req->content($options{query_form_post});
|
||||||
|
} else {
|
||||||
|
my $uri_post = URI->new();
|
||||||
|
if (defined($options{query_form_post})) {
|
||||||
|
$uri_post->query_form($options{query_form_post});
|
||||||
|
}
|
||||||
|
$req->content_type('application/x-www-form-urlencoded');
|
||||||
|
$req->content($uri_post->query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue