From 8c05b81d6860d8e0da4098cc6f59f630d7c53037 Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Tue, 25 Mar 2008 16:29:54 +0000
Subject: * Committing Lulurun's Cgi/Perl implementation of the UGAI servers. *
I love you long time.
---
share/perl/asset.cgi | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 share/perl/asset.cgi
(limited to 'share/perl/asset.cgi')
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 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Carp;
+use MyCGI;
+use OpenSim::Config;
+use OpenSim::Utility;
+use OpenSim::AssetServer;
+
+# !!
+# TODO: ERROR code
+#
+my $param = &MyCGI::getParam();
+my $response = "";
+if ($ENV{REQUEST_METHOD} eq "POST") {
+ my $request = $param->{'POSTDATA'};
+ #&OpenSim::Utility::Log("asset", "request", $ENV{REQUEST_URI}, $request);
+ $response = &OpenSim::AssetServer::saveAsset($request);
+} else { # get
+ eval {
+ my $rest_param = &getRestParam();
+ #&OpenSim::Utility::Log("asset", "request", $ENV{REQUEST_URI});
+ my $rest_param_count = @$rest_param;
+ if ($rest_param_count < 2) {
+ Carp::croak($OpenSim::Config::SYS_MSG{FATAL});
+ }
+ $response = &OpenSim::AssetServer::getAsset($rest_param->[$#$rest_param], $param);
+ };
+ if ($@) {
+ $response = "$@"; # TODO: better return message needed.
+ }
+}
+#&OpenSim::Utility::Log("asset", "response", $response);
+&MyCGI::outputXml("utf-8", $response);
+
+sub getRestParam {
+ my $uri = $ENV{REQUEST_URI} || Carp::croak($OpenSim::Config::SYS_MSG{FATAL});
+ my ($request_uri, undef) = split(/\?/, $uri);
+ $request_uri =~ s/\/$//;
+ my @param = split(/\//, $request_uri);
+ return \@param;
+}
+
--
cgit v1.1