# Copyright (c) 2006-2009 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: Request.pm,v 1.6 2011/08/05 16:49:07 moeller Exp $ package Bivio::Agent::Embed::Request; use strict; use Bivio::Base 'Agent.Request'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.6 $ =~ /\d+/g); my($_HTML) = b_use('Bivio.HTML'); my($_F) = b_use('UI.Facade'); my($_R) = b_use('AgentEmbed.Reply'); sub get_form { my($self) = @_; return $self->get('form'); } sub need_to_secure_task { return 0; } sub new { my(undef, $req, $full_uri, $params) = @_; my($self) = shift->internal_new($params || {}); $self->put_durable( @{$req->map_each(sub { my(undef, $k, $v) = @_; return $k =~ m{ ^(?:client_addr|r|is_secure|timezone|auth_user|super_user_id)$ |\bUserAgent$ }ix ? ($k => $v) : (); })}, parent_request => $req, reply => $_R->new->put(parent_request => $req), embed_level => ($req->unsafe_get('embed_level') || 0) + 1, ); $self->throw_die(DIE => { message => 'embedding too deep; possible nested loop', embed_level => $self->get('embed_level'), parent_request => $self->get('parent_request'), }) if $self->get('embed_level') > 2; if (my $f = $_F->unsafe_get_from_source($req)) { $f->setup_request($self); } $full_uri =~ s/\?(.*)//; my($query) = $1; return $self->internal_initialize_with_uri( $_HTML->unescape($full_uri), $query, )->put(form => undef); } sub unsafe_get_current_root { return undef unless my $self = shift->get_current; foreach my $x (1..10) { return $self unless my $p = $self->unsafe_get('parent_request'); $self = $p; } b_die($self, ': no parent'); # DOES NOT RETURN } 1;