[Jifty-commit] jifty branch, plack, updated. 2908cec6ddbc38c51e63038c4b828f03af310fec
Jifty commits
jifty-commit at lists.jifty.org
Fri Jan 1 04:42:08 EST 2010
The branch, plack has been updated
via 2908cec6ddbc38c51e63038c4b828f03af310fec (commit)
via b4926fafe54b32b8ad123dd3774a25213995e8c2 (commit)
via e831f9dcb399dd597326c8984d45fd6fb57e0c85 (commit)
from 21bca60b9a6106346475903941a1494c83b4977d (commit)
Summary of changes:
lib/Jifty/Response.pm | 11 +++++
lib/Jifty/Test/WWW/Mechanize.pm | 84 +++++++++++++++++++++-----------------
2 files changed, 57 insertions(+), 38 deletions(-)
- Log -----------------------------------------------------------------
commit e831f9dcb399dd597326c8984d45fd6fb57e0c85
Author: Chia-liang Kao <clkao at clkao.org>
Date: Fri Jan 1 17:23:32 2010 +0800
Refactor fragment_request and make send_action provide content-length as well.
diff --git a/lib/Jifty/Test/WWW/Mechanize.pm b/lib/Jifty/Test/WWW/Mechanize.pm
index 3600ff2..ca5bbab 100644
--- a/lib/Jifty/Test/WWW/Mechanize.pm
+++ b/lib/Jifty/Test/WWW/Mechanize.pm
@@ -277,30 +277,39 @@ using the "back button" after making the webservice request.
=cut
+sub _build_webservices_request {
+ my ($self, $endpoint, $data) = @_;
+
+ my $uri = $self->uri->clone;
+ $uri->path($endpoint);
+ $uri->query('');
+
+ my $body = Jifty::YAML::Dump({ path => $endpoint, %$data});
+
+ HTTP::Request->new(
+ POST => $uri,
+ [ 'Content-Type' => 'text/x-yaml',
+ 'Content-Length' => length($body) ],
+ $body
+ );
+}
+
sub send_action {
my $self = shift;
my $class = shift;
my %args = @_;
-
- my $uri = $self->uri->clone;
- $uri->path("__jifty/webservices/yaml");
-
- my $request = HTTP::Request->new(
- POST => $uri,
- [ 'Content-Type' => 'text/x-yaml' ],
- Jifty::YAML::Dump(
- { path => $uri->path,
- actions => {
- action => {
- moniker => 'action',
- class => $class,
- fields => \%args
- }
+ my $request = $self->_build_webservices_request
+ ( "__jifty/webservices/yaml",
+ { actions => {
+ action => {
+ moniker => 'action',
+ class => $class,
+ fields => \%args
}
}
- )
- );
+ });
+
my $result = $self->request( $request );
my $content = eval { Jifty::YAML::Load($result->content)->{action} } || undef;
$self->back;
@@ -319,29 +328,16 @@ sub fragment_request {
my $path = shift;
my %args = @_;
- my $uri = $self->uri->clone;
- $uri->path("__jifty/webservices/xml");
- $uri->query('');
-
- my $body =
- Jifty::YAML::Dump(
- { path => $uri->path,
- fragments => {
- fragment => {
- name => 'fragment',
- path => $path,
- args => \%args
- }
+ my $request = $self->_build_webservices_request
+ ( "__jifty/webservices/xml",
+ { fragments => {
+ fragment => {
+ name => 'fragment',
+ path => $path,
+ args => \%args
}
}
- );
-
- my $request = HTTP::Request->new(
- POST => $uri,
- [ 'Content-Type' => 'text/x-yaml',
- 'Content-Length' => length($body) ],
- $body
- );
+ });
my $result = $self->request( $request );
commit b4926fafe54b32b8ad123dd3774a25213995e8c2
Author: Chia-liang Kao <clkao at clkao.org>
Date: Fri Jan 1 17:29:36 2010 +0800
apply _plack_hook when cloning mech objects.
diff --git a/lib/Jifty/Test/WWW/Mechanize.pm b/lib/Jifty/Test/WWW/Mechanize.pm
index ca5bbab..251bad5 100644
--- a/lib/Jifty/Test/WWW/Mechanize.pm
+++ b/lib/Jifty/Test/WWW/Mechanize.pm
@@ -50,6 +50,18 @@ sub new {
return $self;
}
+sub clone {
+ my $self = shift;
+ my $clone = $self->SUPER::clone($self);
+ $clone->_plack_hook(
+ uri => Jifty->web->url,
+ handler => sub {
+ Jifty->handler->handle_request(@_);
+ },
+ );
+ return $clone;
+}
+
sub _plack_hook {
my $self = shift;
my %args = (
commit 2908cec6ddbc38c51e63038c4b828f03af310fec
Author: Chia-liang Kao <clkao at clkao.org>
Date: Fri Jan 1 17:39:12 2010 +0800
provide response->add_header for compatibility.
diff --git a/lib/Jifty/Response.pm b/lib/Jifty/Response.pm
index e9966b1..a0607c2 100644
--- a/lib/Jifty/Response.pm
+++ b/lib/Jifty/Response.pm
@@ -20,6 +20,17 @@ extends 'Plack::Response';
has 'error' => (is => 'rw');
+=head2 add_header NAME VALUE
+
+Deprecated. Use header(NAME, VALUE)
+
+=cut
+
+sub add_header {
+ my $self = shift;
+ $self->header(@_);
+}
+
=head2 result MONIKER [RESULT]
Gets or sets the L<Jifty::Result> of the L<Jifty::Action> with the given
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list