-# SecureHostingUPG (and presumably other IIS-based gateways?) doesn't like the
-# Host: $site:$port header auto-added by Net::SSLeay, which it adds regardless
-# if you supply one or not
-
-sub _my_post_https ($$$;***) { _my_do_httpx2(POST => 1, @_) }
-
-sub _my_do_httpx2 {
- my ($page, $response, $headers, $server_cert) = &_my_do_httpx3;
- Net::SSLeay::X509_free($server_cert) if defined $server_cert;
- my($h,$v);
- return ($page, $response,
- map( { ($h,$v)=/^(\S+)\:\s*(.*)$/; (uc($h),$v); }
- split(/\s?\n/, $headers)
- )
- );
-}
-
-sub _my_do_httpx3 {
- my ($method, $usessl, $site, $port, $path, $headers,
- $content, $mime_type, $crt_path, $key_path) = @_;
- my ($response, $page, $h,$v);
-
- my $CRLF = $Net::SSLeay::CRLF;
-
- if ($content) {
- $mime_type = "application/x-www-form-urlencoded" unless $mime_type;
- my $len = Net::SSLeay::blength($content);
- $content = "Content-Type: $mime_type$CRLF"
- . "Content-Length: $len$CRLF$CRLF$content";
- } else {
- $content = "$CRLF$CRLF";
- }
-
- my $req = "$method $path HTTP/1.0$CRLF";
- unless ( defined $headers && $headers =~ /^Host:/m ) {
- $req .= "Host: $site";
- unless ( ( $port==80 && !$usessl ) || ( $port==443 && $usessl ) ) {
- $req .= ":$port";
- }
- $req .= $CRLF;
- }
- $req .= (defined $headers ? $headers : '') . "Accept: */*$CRLF$content";
-
- warn "do_httpx3($method,$usessl,$site:$port)" if $Net::SSLeay::trace;
- my ($http, $errs, $server_cert)
- = Net::SSLeay::httpx_cat($usessl, $site, $port, $req, $crt_path, $key_path);
- return (undef, "HTTP/1.0 900 NET OR SSL ERROR$CRLF$CRLF$errs") if $errs;
-
- $http = '' if !defined $http;
- ($headers, $page) = split /\s?\n\s?\n/, $http, 2;
- warn "headers >$headers< page >>$page<< http >>>$http<<<" if $Net::SSLeay::trace>1;
- ($response, $headers) = split /\s?\n/, $headers, 2;
- return ($page, $response, $headers, $server_cert);
-}
-