いまどきでも、Perl で cgi のご依頼も時々あります。
そんなときに必ずぶつかるのが
『 cgi-lib.pl: Unknown Content-type: application/x-www-form-urlencoded;charset=shift_jis 』
au の 特定機種(W53CA,W54CA,etc..)でのみ発生します。
回避策は80行目あたりの
if (!defined $meth || $meth eq '' || $meth eq 'GET' ||
$meth eq 'HEAD' ||
$type eq 'application/x-www-form-urlencoded') {
の部分を下のように変更する。
if (!defined $meth || $meth eq '' || $meth eq 'GET' ||
$meth eq 'HEAD' ||
$type eq 'application/x-www-form-urlencoded' ||
$type eq 'application/x-www-form-urlencoded;charset=shift_jis') {
しかし、これだとPCブラウザでエラーになってしまう。
↓ こんな感じのエラーです。
『 cgi-lib.pl: Request to receive too much data: 175522 bytes 』
au のときだけ処理を変えるのが好ましい。
# UA 取得(モバイル振り分け)
$env2="";
$ag=$ENV{'HTTP_USER_AGENT'};
# UP.Browser が先頭だったらezweb
if(index($ag,"UP.Browser")==0){$env2 = 'au';}
# UP.Browser が先頭でなかったらezweb2
elsif(index($ag,"UP.Browser") > 0){$env2 = 'au';}
if($env2 eq 'au'){
if (!defined $meth || $meth eq '' || $meth eq 'GET' || $meth eq 'HEAD' ||
$type eq 'application/x-www-form-urlencoded' ||
$type eq 'application/x-www-form-urlencoded;charset=shift_jis') {
}else{
if (!defined $meth || $meth eq '' || $meth eq 'GET' || $meth eq 'HEAD' ||
$type eq 'application/x-www-form-urlencoded') {
}
local ($key, $val, $i);
# Read in text
if (!defined $meth || $meth eq '') {
$in = $ENV{'QUERY_STRING'};
$cmdflag = 1; # also use command-line options
↑このような考え方ですが、これでは構文エラーになるので下記のようにします。
# UA 取得(au振り分け)
$URL="";
$ag=$ENV{'HTTP_USER_AGENT'};
if(index($ag,"UP.Browser")==0){$env2 = 'au';}
elsif(index($ag,"UP.Browser") > 0){$env2 = 'au';}
if($env2 eq 'au'){
if (!defined $meth || $meth eq '' || $meth eq 'GET' || $meth eq 'HEAD' ||
$type eq 'application/x-www-form-urlencoded' || $type eq 'application/x-www-form-urlencoded;charset=shift_jis'){
$hogehoge = '1';
}
}else{
if (!defined $meth || $meth eq '' || $meth eq 'GET' || $meth eq 'HEAD' ||
$type eq 'application/x-www-form-urlencoded') {
$hogehoge = '1';
}
}
if ($hogehoge eq '1') {
local ($key, $val, $i);