82 |
|
|
83 |
if ($request =~ m{^GET (/.*) HTTP/1.[01]}) { |
if ($request =~ m{^GET (/.*) HTTP/1.[01]}) { |
84 |
my $method = $1; |
my $method = $1; |
85 |
|
my $param; |
86 |
|
if ( $method =~ s{\?(.+)}{} ) { |
87 |
|
foreach my $p ( split(/[&;]/, $1) ) { |
88 |
|
my ($n,$v) = split(/=/, $p, 2); |
89 |
|
$param->{$n} = $v; |
90 |
|
} |
91 |
|
warn "<< param: ",dump( $param ); |
92 |
|
} |
93 |
if ( my $path = static( $client,$1 ) ) { |
if ( my $path = static( $client,$1 ) ) { |
94 |
warn ">> $path"; |
warn ">> $path"; |
95 |
} elsif ( $method =~ m{/scan} ) { |
} elsif ( $method =~ m{/scan} ) { |
|
my $callback = $1 if $method =~ m{\?callback=([^&;]+)}; |
|
96 |
my $tags = scan_for_tags(); |
my $tags = scan_for_tags(); |
97 |
my $json; |
my $json = {}; |
98 |
map { |
map { |
99 |
my $d = decode_tag($_); |
my $d = decode_tag($_); |
100 |
$d->{sid} = $_; |
$d->{sid} = $_; |
101 |
push @{ $json->{tags} }, $d; |
push @{ $json->{tags} }, $d; |
102 |
} keys %$tags; |
} keys %$tags; |
103 |
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", |
104 |
|
$param->{callback}, "(", to_json($json), ")\r\n"; |
105 |
} else { |
} else { |
106 |
print $client "HTTP/1.0 404 Unkown method\r\n"; |
print $client "HTTP/1.0 404 Unkown method\r\n"; |
107 |
} |
} |