+BEGIN{
+eval 'use bytes; sub blength ($) { length $_[0] }';
+$@ and eval ' sub blength ($) { length $_[0] }' ;
+}
+sub Net::SSLeay::do_httpx3 {
+ my ($method, $usessl, $site, $port, $path, $headers,
+ $content, $mime_type, $crt_path, $key_path) = @_;
+ my ($response, $page, $h,$v);
+ my $CRLF = "\x0d\x0a"; # because \r\n is not fully portable
+ if ($content) {
+ $mime_type = "";#application/x-www-form-urlencoded" unless $mime_type;
+ my $len = blength($content);
+ #$content = "$mime_type${CRLF}Content-Length: $len$CRLF$CRLF$content";
+ $content = "Cache-Control: no-cache$CRLF"
+ . "Content-Type: multipart/form-data; boundary=----FormBoundaryE19zNvXGzXaLvS5C$CRLF"
+ . "Accept: */*$CRLF"
+ . "Content-Length: $len$CRLF$CRLF$content";
+ } else {
+ $content = "$CRLF$CRLF";
+ }
+ my $req = "$method $path HTTP/1.1$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 : '') . "$content";
+
+ warn "do_httpx3($method,$usessl,$site:$port)" if $DEBUG;
+ 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 $DEBUG>1;
+ ($response, $headers) = split /\s?\n/, $headers, 2;
+ return ($page, $response, $headers, $server_cert);
+};
+
+sub Net::SSLeay::make_form {
+ my (@fields) = @_;
+ my $form;
+ while (@fields) {
+ my ($name, $data) = (shift(@fields), shift(@fields));
+# $data =~ s/([^\w\-.\@\$ ])/sprintf("%%%2.2x",ord($1))/gse;
+# $data =~ tr[ ][+];
+ $form .= "$name=$data&";
+ }
+ chop $form;
+ return $form;
+}