Changeset 54
- Timestamp:
- 02/17/06 18:32:59 (3 years ago)
- Files:
-
- atom_client/trunk/lib/AtomClient.pm (modified) (3 diffs)
- atom_client/trunk/lib/My/XML/Atom/Client.pm (modified) (1 diff)
- atom_client/trunk/root/post.tt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
atom_client/trunk/lib/AtomClient.pm
r53 r54 24 24 25 25 my $method = $method_map{$c->req->param('request_method')}; 26 26 27 my $api = My::XML::Atom::Client->new; 27 28 $api->username($c->req->param('username')); 28 29 $api->password($c->req->param('password')); 29 30 30 my ($feed, $request, $response) = $api->$method($c->req->param('resource_uri')); 31 my $entry = XML::Atom::Feed->new(\$c->req->param('request_content')); 32 my ($feed, $request, $response) = $api->$method( $c->req->param('resource_uri'), $entry ); 31 33 32 34 ## ãªã¯ãšã¹ãå … … 36 38 $c->stash->{request_header} .= $_ . ": " . $request->header($_) . "\n"; 37 39 } 40 $c->stash->{request_content} .= $request->content; 41 38 42 ## ã¬ã¹ãã³ã¹å 39 43 容 … … 44 48 } 45 49 46 $c->stash->{response_content} .= $feed->as_xml ;50 $c->stash->{response_content} .= $feed->as_xml if defined $feed; 47 51 } 48 52 atom_client/trunk/lib/My/XML/Atom/Client.pm
r51 r54 21 21 } 22 22 23 sub createEntry { 24 my $client = shift; 25 my($uri, $entry) = @_; 26 return $client->error("Must pass a PostURI before posting") 27 unless $uri; 28 my $req = HTTP::Request->new(POST => $uri); 29 $req->content_type('application/x.atom+xml'); 30 my $xml = $entry->as_xml; 31 _utf8_off($xml); 32 $req->content_length(length $xml); 33 $req->content($xml); 34 my $res = $client->make_request($req); 35 #return $client->error("Error on POST $uri: " . $res->status_line) 36 # unless $res->code == 201; 37 $res->header('Location') || 1; 38 39 return (undef, $req, $res); 40 } 41 42 sub _utf8_off { 43 if ($] >= 5.008) { 44 require Encode; 45 Encode::_utf8_off($_[0]); 46 } 47 } 48 23 49 1; atom_client/trunk/root/post.tt
r49 r54 8 8 <h3>content</h3> 9 9 <pre id="request_content"> 10 [% request_content %]10 [% request_content | html %] 11 11 </pre> 12 12
