diff options
author | Adam Frisby | 2008-03-25 16:29:54 +0000 |
---|---|---|
committer | Adam Frisby | 2008-03-25 16:29:54 +0000 |
commit | 8c05b81d6860d8e0da4098cc6f59f630d7c53037 (patch) | |
tree | 3325e09660ee8ad5a12cc19c8da6c4bd8bff5c21 /share/perl/asset.cgi | |
parent | * On Ray casting. Now returning the face normal of the collision face. (diff) | |
download | opensim-SC_OLD-8c05b81d6860d8e0da4098cc6f59f630d7c53037.zip opensim-SC_OLD-8c05b81d6860d8e0da4098cc6f59f630d7c53037.tar.gz opensim-SC_OLD-8c05b81d6860d8e0da4098cc6f59f630d7c53037.tar.bz2 opensim-SC_OLD-8c05b81d6860d8e0da4098cc6f59f630d7c53037.tar.xz |
* Committing Lulurun's Cgi/Perl implementation of the UGAI servers.
* I love you long time.
Diffstat (limited to 'share/perl/asset.cgi')
-rw-r--r-- | share/perl/asset.cgi | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/share/perl/asset.cgi b/share/perl/asset.cgi new file mode 100644 index 0000000..318e06f --- /dev/null +++ b/share/perl/asset.cgi | |||
@@ -0,0 +1,43 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | |||
3 | use strict; | ||
4 | use Carp; | ||
5 | use MyCGI; | ||
6 | use OpenSim::Config; | ||
7 | use OpenSim::Utility; | ||
8 | use OpenSim::AssetServer; | ||
9 | |||
10 | # !! | ||
11 | # TODO: ERROR code | ||
12 | # | ||
13 | my $param = &MyCGI::getParam(); | ||
14 | my $response = "<ERROR />"; | ||
15 | if ($ENV{REQUEST_METHOD} eq "POST") { | ||
16 | my $request = $param->{'POSTDATA'}; | ||
17 | #&OpenSim::Utility::Log("asset", "request", $ENV{REQUEST_URI}, $request); | ||
18 | $response = &OpenSim::AssetServer::saveAsset($request); | ||
19 | } else { # get | ||
20 | eval { | ||
21 | my $rest_param = &getRestParam(); | ||
22 | #&OpenSim::Utility::Log("asset", "request", $ENV{REQUEST_URI}); | ||
23 | my $rest_param_count = @$rest_param; | ||
24 | if ($rest_param_count < 2) { | ||
25 | Carp::croak($OpenSim::Config::SYS_MSG{FATAL}); | ||
26 | } | ||
27 | $response = &OpenSim::AssetServer::getAsset($rest_param->[$#$rest_param], $param); | ||
28 | }; | ||
29 | if ($@) { | ||
30 | $response = "<ERROR>$@</ERROR>"; # TODO: better return message needed. | ||
31 | } | ||
32 | } | ||
33 | #&OpenSim::Utility::Log("asset", "response", $response); | ||
34 | &MyCGI::outputXml("utf-8", $response); | ||
35 | |||
36 | sub getRestParam { | ||
37 | my $uri = $ENV{REQUEST_URI} || Carp::croak($OpenSim::Config::SYS_MSG{FATAL}); | ||
38 | my ($request_uri, undef) = split(/\?/, $uri); | ||
39 | $request_uri =~ s/\/$//; | ||
40 | my @param = split(/\//, $request_uri); | ||
41 | return \@param; | ||
42 | } | ||
43 | |||