Skip to content

Instantly share code, notes, and snippets.

@perbu
Created May 11, 2016 10:48
Show Gist options
  • Save perbu/4b143c400c5394837db70e6aa23041a3 to your computer and use it in GitHub Desktop.
Save perbu/4b143c400c5394837db70e6aa23041a3 to your computer and use it in GitHub Desktop.
#!/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