kafsemo.org

Special-Casing GETs for TextDrive

2005-12-04

I’ve just noticed that GET requests for Robert Sayre’s blog were failing with ‘412 Precondition Failed’. It turns out that this is due to some User-Agent checks by his website’s hosting company, TextDrive, as part of their abuse prevention. (Search for: TextDrive 412.) This really is the sort of thing that slowly breaks the web, but it is their decision. Either way, I’d quite like to read that blog:

...
use NetAddr::IP;
use URI;
...
# From whois NEXTLVL-046-TEXTDRV-1 | grep ^CIDR
my $textdriveNetblock = new NetAddr::IP('207.7.108.0/24');
...
# Special case for TextDrive
my $u = new URI($location);
if ($u->host) {
  my $hostaddr = new NetAddr::IP($u->host);
  if ($hostaddr && $textdriveNetblock->contains($hostaddr)) {
    $req->header('User-Agent', 'Bad-Abuse-Prevention-Sucks/0.0');
  }
}

It makes me feel like a criminal (worse – a spammer!), but it works.

(Music: The New Pornographers, “Three or Four”)
(More from this year, or the front page? [K])