source: gs3-extensions/meandre/trunk/src/cgi-bin/cors-proxy.pl@ 28546

Last change on this file since 28546 was 28546, checked in by davidb, 10 years ago

CGI scripts that help the Greenstone-Meandre extension run smoothly at runtime

  • Property svn:executable set to *
File size: 956 bytes
Line 
1#!/usr/bin/perl -w
2
3use strict;
4
5##use CGI;
6
7
8use LWP;
9
10
11
12
13
14
15sub main
16{
17 # my $cgi = new CGI();
18
19
20 print STDOUT "Access-Control-Allow-Origin: *\n";
21
22
23
24
25
26
27
28 # print STDOUT "<html><body>".$ENV{"QUERY_STRING"}."</body></html>\n";
29
30 my $query_string = $ENV{"QUERY_STRING"};
31 if (defined $query_string) {
32
33
34
35 my $browser = LWP::UserAgent->new;
36
37
38 my $url = $query_string;
39
40 my $response = $browser->get($url);
41
42 if ($response->is_success) {
43
44 print STDOUT "Content-type:" . $response->content_type ."\n\n";
45 print STDOUT $response->content;
46
47 }
48 else {
49 # did not exist
50 print STDOUT "Status: 404 Not Found\n";
51 print STDOUT "Content-type:text/html\n\n";
52 print STDOUT "<html><body><p>Error: Failed to retrieve $url</body></html>\n";
53
54 }
55
56 }
57 else {
58 print STDOUT "Content-type:text/html\n\n";
59 print STDOUT "<html><body><p>Error: No GET arguments found in QUERY_STRING</body></html>\n";
60
61 }
62
63
64
65
66}
67
68main();
Note: See TracBrowser for help on using the repository browser.