From 6fa58fcd80d1a16245a5ef736771368ca1d40f86 Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Tue, 29 Jan 2002 17:16:35 +0000 Subject: [w3m-dev 02927] mailto: POST method with w3mmail.cgi * file.c (loadGeneralFile): pass request even if SCM_UNKNOWN (for external URI loader) * scripts/w3mmail.cgi.in: support POST method From: SASAKI Takeshi --- scripts/w3mmail.cgi.in | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'scripts/w3mmail.cgi.in') diff --git a/scripts/w3mmail.cgi.in b/scripts/w3mmail.cgi.in index 9cfe5a0..48aa567 100755 --- a/scripts/w3mmail.cgi.in +++ b/scripts/w3mmail.cgi.in @@ -1,6 +1,6 @@ #!@PERL@ -$rcsid = q$Id: w3mmail.cgi.in,v 1.8 2002/01/29 16:31:09 ukai Exp $; +$rcsid = q$Id: w3mmail.cgi.in,v 1.9 2002/01/29 17:16:35 ukai Exp $; ($id = $rcsid) =~ s/^.*,v ([\d\.]*).*/$1/; ($prog=$0) =~ s/.*\///; @@ -25,8 +25,16 @@ if ($query =~ s/^\w+://) { @to = ($to); push(@to, $opt{'to'}) if ($opt{'to'}); $opt{'to'} = join(',', @to); - $body = $opt{'body'}; - delete $opt{'body'}; + if ($ENV{'REQUEST_METHOD'} eq 'POST') { + sysread(STDIN, $body, $ENV{'CONTENT_LENGTH'}); + $content_type = $ENV{'CONTENT_TYPE'}; + if ($content_type =~ /^multipart\/form-data;\s+boundary=(.*)$/) { + $boundary = $1; + } + } else { + $body = $opt{'body'}; + delete $opt{'body'}; + } &lang_setup; print "Content-Type: text/html\r\n"; @@ -49,6 +57,10 @@ if ($query =~ s/^\w+://) { print "\u$h:\n"; delete $opt{$h}; } + if ($boundary) { + print "Content-Type:multipart/form-data; boundary=\"$boundary\"\n"; + print "\n"; + } foreach $h (keys %opt) { $qh = &html_quote($h); $v = &lang_html_quote($opt{$h}); @@ -80,6 +92,8 @@ if ($query =~ s/^\w+://) { delete $opt{'body'}; $act = $opt{'action'}; delete $opt{'action'}; + $boundary = $opt{'boundary'}; + delete $opt{'boundary'}; &lang_setup; if ($act eq "Preview") { @@ -103,7 +117,12 @@ if ($query =~ s/^\w+://) { } ($cs,$cte,$body) = &lang_body(&lang_html_quote($body), 0); print "Mime-Version: 1.0\n"; - print "Content-Type: text/plain; charset=$cs\n"; + if ($boundary) { + print "Content-Type: multipart/form-data;\n"; + print " boundary=\"$boundary\"\n"; + } else { + print "Content-Type: text/plain; charset=$cs\n"; + } # print "Content-Transfer-Encoding: $cte\n"; print "User-Agent: $ENV{'SERVER_SOFTWARE'} $prog/$id\n"; print "\n"; @@ -122,6 +141,10 @@ if ($query =~ s/^\w+://) { print "\u$h:\n"; delete $opt{$h}; } + if ($boundary) { + print "Content-Type:Content-Type: multipart/form-data; boundary=\"$boundary\"\n"; + print "\n"; + } foreach $h (keys %opt) { $qh = &html_quote($h); print "\u$qh:$v{$h}\n"; @@ -154,7 +177,12 @@ if ($query =~ s/^\w+://) { } ($cs,$cte,$body) = &lang_body($body, 1); print MAIL "Mime-Version: 1.0\n"; - print MAIL "Content-Type: text/plain; charset=$cs\n"; + if ($boundary) { + print MAIL "Content-Type: multipart/form-data;\n"; + print MAIL " boundary=\"$boundary\"\n"; + } else { + print MAIL "Content-Type: text/plain; charset=$cs\n"; + } print MAIL "Content-Transfer-Encoding: $cte\n"; print MAIL "User-Agent: $ENV{'SERVER_SOFTWARE'} $prog/$id\n"; print MAIL "\n"; -- cgit v1.2.3