-fail "non-hexadecimal packet length" unless $len_hex =~ m{^[0-9a-zA-Z]{4}$};
-my $len = hex $len_hex;
-
-my $line = xread $len;
-unless ($line =~ m{^git-upload-pack (?:~($TILDE)/)?($REPO[.]git)\0host=($HOSTNAME)\0$}) {
- $line =~ s/[^ -~]+/ /g;
+fail "non-hex packet length" unless $len_hex =~ m{^[0-9a-fA-F]{4}$};
+my $line = xread hex $len_hex;
+if ($line =~ m{^(git-[a-z-]+) ([!-~]+)\0host=([!-~]+)\0$}) {
+ package cf;
+ our ($service,$path,$host) = ($1,$2,$3);
+ $path =~ s|^/*||;
+ our $uri = $_ = "git://$host/$path";
+} else {
+ $line =~ s|[^ -~]+| |g;