Index: /trunk/DataStore/lib/DataStore/Product.pm
===================================================================
--- /trunk/DataStore/lib/DataStore/Product.pm	(revision 6583)
+++ /trunk/DataStore/lib/DataStore/Product.pm	(revision 6584)
@@ -1,5 +1,5 @@
 # Copyright (C) 2006  Joshua Hoblitt
 #
-# $Id: Product.pm,v 1.2 2006-03-08 00:02:43 jhoblitt Exp $
+# $Id: Product.pm,v 1.3 2006-03-14 23:24:05 jhoblitt Exp $
 
 package DataStore::Product;
@@ -14,5 +14,8 @@
 
 use Carp qw( carp );
+use DataStore::FileSet::Parser;
 use DataStore::Record;
+use DataStore::Response;
+use LWP::UserAgent;
 use Params::Validate qw( validate SCALAR);
 
@@ -108,7 +111,39 @@
 sub request 
 {
+    my $self = shift;
 
+    # no params
+    validate(@_, {});
+
+    # make request
+    my $ua = LWP::UserAgent->new;
+    my $request = HTTP::Request->new(GET => $self->uri);
+    my $response = $ua->request($request);
+
+    if (! $response->is_success) {
+        carp $response->status_line;
+        return undef;
+    }
+
+    # parse document
+    my $parser = DataStore::FileSet::Parser->new;
+
+    my $data = $parser->parse($response->content);
+
+    unless ($data) {
+        carp "Product contains no FileSets";
+        return undef;
+    }
+
+
+    # return DS::Response object
+    my $dsr = DataStore::Response->new(
+        is_success  => 1,
+        code        => $response->code,
+        status_line => $response->status_line,
+        data        => $data,
+        request     => $self,
+    );
 }
-
 
 1;
Index: /trunk/DataStore/t/05_product.t
===================================================================
--- /trunk/DataStore/t/05_product.t	(revision 6583)
+++ /trunk/DataStore/t/05_product.t	(revision 6584)
@@ -3,5 +3,5 @@
 # Copyright (C) 2006  Joshua Hoblitt
 #
-# $Id: 05_product.t,v 1.1 2006-03-08 00:02:43 jhoblitt Exp $
+# $Id: 05_product.t,v 1.2 2006-03-14 23:24:05 jhoblitt Exp $
 
 use strict;
@@ -10,5 +10,5 @@
 use lib qw( ./lib ./t );
 
-use Test::More tests => 10;
+use Test::More tests => 21;
 
 =head1 NAME
@@ -99,2 +99,69 @@
 # ->request()
 
+use Net::HTTPServer;
+
+sub bar 
+{
+    my $req = shift;             # Net::HTTPServer::Request object
+    my $res = $req->Response();  # Net::HTTPServer::Response object
+
+    my $string = <<END;
+# filesetID|time registered    |type   |telescope pointing         |etime|f|airmass|
+otis0123456|2006-01-01T00:03:04Z|object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23   |
+otis0123456|2006-01-01T00:03:04Z|object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23   |
+otis0123456|2006-01-01T00:03:04Z|object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23   |
+otis0123456|2006-01-01T00:03:04Z|object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23   |
+END
+
+    $res->Print($string);
+
+    return $res;
+}
+
+$|++;
+
+$SIG{CHLD} = 'IGNORE';
+my $pid = open(my $child, "-|");
+
+unless ($pid) {
+    my $server = new Net::HTTPServer( port => 'scan' );
+
+    # send port number to parent
+    print $server->Start(), "\n";
+
+    $server->RegisterURL('/', \&bar);
+    $server->Process();  # Run forever
+
+    exit -1;
+}
+
+my $port = <$child>;
+chomp $port;
+
+{
+    my $dsp = DataStore::Product->new( uri => "http://localhost:$port/" );
+
+    isa_ok($dsp->request, 'DataStore::Response');
+}
+
+{
+    my $dsp = DataStore::Product->new( uri => "http://localhost:$port/" );
+
+    my $dsr = $dsp->request;
+
+    ok($dsr->is_success, "response->is_success() is correct");
+    is($dsr->code, 200, "response->code() is correct");
+    is($dsr->status_line, "200 OK", "response->status_line() is correct");
+    is(ref $dsr->data, 'ARRAY', "response->data is arrayref is correct");
+    isa_ok($dsr->request, 'DataStore::Record');
+
+    my $data = $dsr->data;
+    is(scalar @$data, 4, "data has the correct number of rows");
+    isa_ok(@$data[0], 'DataStore::FileSet', "data has correct type of rows");
+    isa_ok(@$data[1], 'DataStore::FileSet', "data has correct type of rows");
+    isa_ok(@$data[2], 'DataStore::FileSet', "data has correct type of rows");
+    isa_ok(@$data[3], 'DataStore::FileSet', "data has correct type of rows");
+}
+
+# cleanup HTTP server
+kill 9, $pid;
