Created
May 11, 2016 10:48
-
-
Save perbu/4b143c400c5394837db70e6aa23041a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Digest::MD5 qw(md5); | |
use base qw(Net::Server::HTTP); | |
__PACKAGE__->run( | |
port => [8080], | |
); | |
sub process_http_request { | |
my $self = shift; | |
my $str = substr( md5($ENV{'REQUEST_URI'}), 0, 4 ); | |
my $ab; | |
# Just do some simple hashing. | |
if (unpack('L', $str) % 2 == 0) { | |
$ab = 'A'; | |
} else { | |
$ab = ‘B’; | |
} | |
print "X-decision: $ab\n"; | |
print "Content-type: text/html\n\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment