This example is a simple subroutine to check whether the content is a MMS and write to a file. Combine the example in “Detect WAP browser and redirect to different url in Perl”, you can route the URL request to another URL if it is not a MMS content.
The subroutine “doRedirrect” is meant to do that, or you can do a simple print message to state that this requested URL is for MMS.
The following is the code for this:
sub doMMSC {
my $class=shift;
my $length = $ENV{'CONTENT_LENGTH'};
if ($ENV{'CONTENT_TYPE'} ne "application/vnd.wap.mms-message") {
&doRedirrect;
return;
}
my $count = read(STDIN, $body, $length);
if ($count == $length) {
open ER, ">incoming.mms";
print ER $body;
close ER;
}
}