--- 3m-810.pl 2009/06/23 13:29:10 45 +++ 3m-810.pl 2009/06/23 13:50:13 46 @@ -82,18 +82,26 @@ if ($request =~ m{^GET (/.*) HTTP/1.[01]}) { my $method = $1; + my $param; + if ( $method =~ s{\?(.+)}{} ) { + foreach my $p ( split(/[&;]/, $1) ) { + my ($n,$v) = split(/=/, $p, 2); + $param->{$n} = $v; + } + warn "<< param: ",dump( $param ); + } if ( my $path = static( $client,$1 ) ) { warn ">> $path"; } elsif ( $method =~ m{/scan} ) { - my $callback = $1 if $method =~ m{\?callback=([^&;]+)}; my $tags = scan_for_tags(); - my $json; + my $json = {}; map { my $d = decode_tag($_); $d->{sid} = $_; push @{ $json->{tags} }, $d; } keys %$tags; - print $client "HTTP/1.0 200 OK\r\nContent-Type: application/x-javascript\r\n\r\n$callback(", to_json($json), ")\r\n"; + print $client "HTTP/1.0 200 OK\r\nContent-Type: application/x-javascript\r\n\r\n", + $param->{callback}, "(", to_json($json), ")\r\n"; } else { print $client "HTTP/1.0 404 Unkown method\r\n"; }