view release on metacpan or search on metacpan
lib/TSVRPC/Client.pm view on Meta::CPAN
sub call {
my ( $self, $method, $args, $req_encoding ) = @_;
$req_encoding ||= 'B'; # default encoding is base64. because base64 is very fast.
my $content = TSVRPC::Parser::encode_tsvrpc($args, $req_encoding);
my $furl = $self->{furl};
my %special_headers = ('content-type' => undef);
my ( $minor_version, $code, $msg, $headers, $body ) = $furl->request(
url => $self->{base} . $method,
headers => [
"Content-Type" => "text/tab-separated-values; colenc=$req_encoding",
"Content-Length" => length($content),
lib/TSVRPC/Client.pm view on Meta::CPAN
method => 'POST',
content => $content,
special_headers => \%special_headers,
);
my $decoded_body;
if (my $content_type = $special_headers{'content-type'}) {
my $res_encoding = TSVRPC::Util::parse_content_type( $content_type );
$decoded_body = defined($res_encoding) ? TSVRPC::Parser::decode_tsvrpc( $body, $res_encoding ) : undef;
}
return ($code, $decoded_body, $msg);
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CallBackery.pm view on Meta::CPAN
has securityHeaders => sub { {
# prevent click jacking
'X-Frame-Options' => 'SAMEORIGIN',
# some magic browser based anti xss action
'X-XSS-Protection' => '1; mode=block',
# the browser should obej the servers settings regarding content-type
'X-Content-Type-Options' => 'nosniff',
# do not store our data ever
'Pragma' => 'private',
}};
view all matches for this distribution
view release on metacpan or search on metacpan
examples/basic_example.pl view on Meta::CPAN
$h->meta({
'http-equiv' => 'expires',
'content' => '-1',
}),
$h->meta({
'http-equiv' => 'content-type',
'content' => 'text/html; charset=UTF-8',
}),
$h->title('Peoplesign Perl integration demo'),
]),
$h->body([
view all matches for this distribution
view release on metacpan or search on metacpan
static/orig/js/jquery.js view on Meta::CPAN
/*! jQuery v1.7.2 jquery.com | jquery.org/license */
(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("ifram...
a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3]....
.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(argumen...
view all matches for this distribution
view release on metacpan or search on metacpan
t/live-test.t view on Meta::CPAN
my $mech = Test::WWW::Mechanize::Catalyst->new;
# 2-4
$mech->get_ok('http://localhost/', 'get main page');
$mech->content_like(qr/it works/i, 'see if it has our text');
is $mech->response->headers->{'content-type'}, 'text/html; charset=utf-8',
'No Accept header = text/html';
$mech->add_header( Accept => 'text/html' );
# 5-7
$mech->get_ok('http://localhost/', 'get main page');
$mech->content_like(qr/it works/i, 'see if it has our text');
is $mech->response->headers->{'content-type'}, 'text/html; charset=utf-8',
'Accept header of text/html = text/html';
$mech->add_header( Accept => 'application/xhtml+xml' );
# 8-10
$mech->get_ok('http://localhost/', 'get main page');
$mech->content_like(qr/it works/i, 'see if it has our text');
is $mech->response->headers->{'content-type'}, 'application/xhtml+xml; charset=utf-8',
'Accept xhtml gives content type application/xhtml+xml';
# 11-13
$mech->get_ok('http://localhost/nothtml', 'get nothtml page');
$mech->content_like(qr/not html/i, 'see if it has our text');
is $mech->response->headers->{'content-type'}, 'application/json',
'application/json is unmolested';
# 14-16
$mech->add_header( Accept => 'text/html, application/xhtml+xml');
$mech->get_ok('http://localhost/', 'get main page');
$mech->content_like(qr/it works/i, 'see if it has our text');
is $mech->response->headers->{'content-type'}, 'application/xhtml+xml; charset=utf-8',
'Accept xhtml AND html gives content type application/xhtml+xml';
# 17-19
$mech->add_header( Accept => 'text/html, application/xhtml+xml;q=0');
$mech->get_ok('http://localhost/', 'get main page');
$mech->content_like(qr/it works/i, 'see if it has our text');
is $mech->response->headers->{'content-type'}, 'text/html; charset=utf-8',
'Accept header of application/xhtml+xml with q value of 0 and text/html = text/html';
# 20-22
$mech->add_header( Accept => 'text/html;q=0, application/xhtml+xml');
$mech->get_ok('http://localhost/', 'get main page');
$mech->content_like(qr/it works/i, 'see if it has our text');
is $mech->response->headers->{'content-type'}, 'application/xhtml+xml; charset=utf-8',
'Accept html with a q value of 0 gives content type application/xhtml+xml';
# 23-25
$mech->add_header( Accept => '*/*');
$mech->get_ok('http://localhost/', 'get main page');
$mech->content_like(qr/it works/i, 'see if it has our text');
is $mech->response->headers->{'content-type'}, 'text/html; charset=utf-8',
'Accept */* content type text/html';
# 26-28
$mech->add_header( Accept => '*/*, application/xhtml+xml');
$mech->get_ok('http://localhost/', 'get main page');
$mech->content_like(qr/it works/i, 'see if it has our text');
is $mech->response->headers->{'content-type'}, 'application/xhtml+xml; charset=utf-8',
'Accept */* and application/xhtml+xml gives content type application/xhtml+xml';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Action/Deserialize.pm view on Meta::CPAN
=head1 DESCRIPTION
This action will deserialize HTTP POST, PUT, OPTIONS and DELETE requests.
It assumes that the body of the HTTP Request is a serialized object.
The serializer is selected by introspecting the requests content-type
header.
If you want deserialize any other HTTP method besides POST, PUT,
OPTIONS and DELETE you can do this by setting the
C<< deserialize_http_methods >> list via C<< action_args >>.
lib/Catalyst/Action/Deserialize.pm view on Meta::CPAN
}
);
See also L<Catalyst::Controller/action_args>.
The specifics of deserializing each content-type is implemented as
a plugin to L<Catalyst::Action::Deserialize>. You can see a list
of currently implemented plugins in L<Catalyst::Controller::REST>.
The results of your Deserializing will wind up in $c->req->data.
This is done through the magic of L<Catalyst::Request::REST>.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Action/Serialize/SimpleExcel.pm view on Meta::CPAN
In your javascript, to initiate a file download:
// this uses jQuery
function export_to_excel() {
$('<iframe '
+'src="/rest/books?content-type=application%2Fvnd.ms-excel">')
.hide().appendTo('body');
}
Note, the content-type query param is required if you're just linking to the
action. It tells L<Catalyst::Controller::REST> what you're serializing the data
as.
=head1 DESCRIPTION
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Action/Serialize/SimpleXLSX.pm view on Meta::CPAN
<script>
$(document).ready(function () {
function export_to_excel() {
$('<iframe ' + 'src="/item?content-type=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">').hide().appendTo('body');
}
$("#books").on("click", export_to_excel);
});
</script>
Note, the content-type query param is required if you're just linking to the
action. It tells L<Catalyst::Controller::REST> what you're serializing the data
as.
=head1 DESCRIPTION
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/ActionRole/Public.pm view on Meta::CPAN
$ctx->stash(public_file =>
(my $full_path = $ctx->config->{root}->file(@path_parts)));
unless($self->path_is_allowed_content_type($full_path)) {
$ctx->log->debug("File '$full_path' is not allowed content-type") if $ctx->debug;
return 0;
}
if($self->is_real_file($full_path)) {
$ctx->log->debug("Serving File: $full_path for action $self") if $ctx->debug;
view all matches for this distribution
view release on metacpan or search on metacpan
Revision history for Catalyst-Controller-Imager
0.06 2014-01-12
* added a mocked $c->stash() method to make failing tests work again
* stringified MIME content-type value to avoid errors in latest
Catalyst version
0.05 2013-02-22
* added the requested file path to the error message in case a file
was not found [Alexander Kohsiek]
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Action/SOAP.pm view on Meta::CPAN
};
if ($@) {
$c->stash->{soap}->fault({ code => 'SOAP-ENV:Client', reason => 'Bad XML Message', detail => $@});
}
} else {
$c->stash->{soap}->fault({ code => 'SOAP-ENV:Client', reason => 'Bad content-type/method'});
}
}
};
1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Engine/XMPP2.pm view on Meta::CPAN
=item Content-Type
XMPP has no support for MIME types. Every message is, by definition, a
XML document. So every request will have the "application/xml" MIME
type. If the response content-type is also "application/xml", it will
be written as raw into the XMPP stream. This will allow SOAP
responses, for instance, to be sent as in XEP-0072.
On the other hand, if the content type is of some other type, it will
be sent as literal string inside a <body> tag, as described by XMPP
view all matches for this distribution
view release on metacpan or search on metacpan
0.09 11 October 2010
- Allow for no data to be sent
- Include all methods, including DELETE
0.08 7 October 2010
- *NB* The attribute "type" now uses the content-type, so valid values are
application/json, application/xml, application/yaml.
More may come if needed.
0.07 5 October 2010
- Data::Serializable needs to be 0.40.1 for XML tests to pass
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/CustomErrorMessage.pm view on Meta::CPAN
use Catalyst qw( CustomErrorMessage );
# optional (values in this example are the defaults)
__PACKAGE__->config->{'custom-error-message'}->{'uri-for-not-found'} = '/';
__PACKAGE__->config->{'custom-error-message'}->{'error-template'} = 'error.tt2';
__PACKAGE__->config->{'custom-error-message'}->{'content-type'} = 'text/html; charset=utf-8';
__PACKAGE__->config->{'custom-error-message'}->{'view-name'} = 'TT';
__PACKAGE__->config->{'custom-error-message'}->{'response-status'} = 500;
=head1 DESCRIPTION
lib/Catalyst/Plugin/CustomErrorMessage.pm view on Meta::CPAN
$c->config->{'custom-error-message'}->{'view-name'} = 'Mason';
Content-type and response status can be configured via:
$c->config->{'custom-error-message'}->{'content-type'} = 'text/plain; charset=utf-8';
$c->config->{'custom-error-message'}->{'response-status'} = 500;
=cut
sub finalize_error {
lib/Catalyst/Plugin/CustomErrorMessage.pm view on Meta::CPAN
# render the template
my $action_name = $c->action->reverse;
$c->stash->{'finalize_error'} = $action_name.': '.$error;
$c->response->content_type(
$config->{'content-type'}
||
'text/html; charset=utf-8'
);
my $view_name = $config->{'view-name'} || 'TT';
eval {
view all matches for this distribution
view release on metacpan or search on metacpan
0.10 2005-09-13 14:00:00
- Fixed bug in cache key generation that ignored duplicate key names.
- Fixed bug where clear_cached_page called with a regex did not
properly remove the page from cache.
- Fixed bug where cache metadata was not set properly if
content-type or content-encoding was missing.
- Added test suite.
- Code cleanup per Best Practices.
0.09 2005-06-27 11:25:00
- Removed dependence on HTTP::Date.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/ServeFile.pm view on Meta::CPAN
my $full_path = File::Spec->catfile($root, $file_proto);
my $content_type = Plack::MIME->mime_type($full_path) || 'application/octet';
if(my $allowed_content_types = $settings{allowed_content_types}) {
unless(scalar( grep { lc($content_type) eq lc($_) } @$allowed_content_types)) {
$c->log->debug("Static file has disallowed content-type of '$content_type'") if $c->debug;
return;
}
}
my ($fh, @stat) = $c->$get_asset_from_filesystem($full_path);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/Session/CGISession.pm view on Meta::CPAN
# QUESTIONS:
#
#
# Shouldn't the body text rewrite in finalize be limited to
# content-type qr{text/x?html} ?
#
# Should extracting embedded session ids from paths be conditional
# on {rewrite}? That is, we shouldn't do it unless allowed
# by config.
#
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/Snippets.pm view on Meta::CPAN
This is false by default.
=item content_type
When the formatter type is C<plain> you may use this field to specify the
content-type header to use.
This option defaults to C<text/plain>.
=item json_content_type
view all matches for this distribution
view release on metacpan or search on metacpan
t/04static.t view on Meta::CPAN
plan tests => ($has_space_file) ? 12 : 9;
use Catalyst::Test 'TestApp';
# test getting a css file
ok( my $res = request('http://localhost/files/static.css'), 'request ok' );
is( $res->content_type, 'text/css', 'content-type text/css ok' );
like( $res->content, qr/background/, 'content of css ok' );
# test a file with spaces
if ( $has_space_file ) {
ok( $res = request('http://localhost/files/space file.txt'), 'request ok' );
is( $res->content_type, 'text/plain', 'content-type text/plain ok' );
like( $res->content, qr/background/, 'content of space file ok' );
}
# test a non-existent file
ok( $res = request('http://localhost/files/404.txt'), 'request ok' );
view all matches for this distribution
view release on metacpan or search on metacpan
t/04static.t view on Meta::CPAN
plan tests => ($has_space_file) ? 12 : 9;
use Catalyst::Test 'TestApp';
# test getting a css file
ok( my $res = request('http://localhost/files/static.css'), 'request ok' );
is( $res->content_type, 'text/css', 'content-type text/css ok' );
like( $res->content, qr/background/, 'content of css ok' );
# test a file with spaces
if ( $has_space_file ) {
ok( $res = request('http://localhost/files/space file.txt'), 'request ok' );
is( $res->content_type, 'text/plain', 'content-type text/plain ok' );
like( $res->content, qr/background/, 'content of space file ok' );
}
# test a non-existent file
ok( $res = request('http://localhost/files/404.txt'), 'request ok' );
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/UploadProgress/Static.pm view on Meta::CPAN
if (hdrName != null) {
this._headers[this._headers.length] = {h:hdrName, v:hdrValue};
switch (hdrName.toLowerCase()) {
case 'content-encoding': gotContentEncoding = true; break;
case 'content-length' : gotContentLength = true; break;
case 'content-type' : gotContentType = true; break;
case 'date' : gotDate = true; break;
case 'expires' : gotExpiration = true; break;
case 'last-modified' : gotLastModified = true; break;
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst.pm view on Meta::CPAN
To turn it off for a single request use the L<clear_encoding>
method to turn off encoding for this request. This can be useful
when you are setting the body to be an arbitrary block of bytes,
especially if that block happens to be a block of UTF8 text.
Encoding is automatically applied when the content-type is set to
a type that can be encoded. Currently we encode when the content type
matches the following regular expression:
$content_type =~ /^text|xml$|javascript$/
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/ActionRole/ProvidesMedia.pm view on Meta::CPAN
L<Catalyst::TraitFor::Request::REST> (which comes with the L<Catalyst::Action::REST>
distribution) defines a method 'accepted_content_types' which returns an array of
content types that the client accepts, sorted in order by inspecting the ACCEPT
header. However for GET requests this is overridden and instead we return the
request content-type if one exists. I'm not sure this is exactly correct.
=head1 METHODS
This role contains the following methods.
view all matches for this distribution
view release on metacpan or search on metacpan
my $req = $class->new(
_log => Catalyst::Log->new,
);
$req->{_context} = 'MockContext';
$req->method('GET');
$req->parameters( { 'content-type' => 'text/json' } );
$req->headers( HTTP::Headers->new() );
ok(
!$req->looks_like_browser(),
'forced non-HTML content-type is not a browser'
);
}
{
my $req = $class->new(
_log => Catalyst::Log->new,
);
$req->{_context} = 'MockContext';
$req->method('GET');
$req->parameters( { 'content-type' => 'text/html' } );
$req->headers( HTTP::Headers->new() );
ok(
$req->looks_like_browser(),
'forced HTML content-type is not a browser'
);
}
{
my $req = $class->new(
view all matches for this distribution
view release on metacpan or search on metacpan
CCCCCCCCCCCCCCCCCCCCCCCC
EOT
my $fasta = request('/fasta');
is $fasta->content, $fasta_output, 'Fasta rendering';
is $fasta->content_type, 'application/x-fasta', 'content-type is right';
my $default = request('/');
is $default->content, $fasta_output, 'Default format';
is $default->content_type, 'application/x-fasta', 'content-type is right';
done_testing;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/View/CSV.pm view on Meta::CPAN
# Record suffix
$self->suffix ( $config->{suffix} );
delete $config->{suffix};
# Record content-type
$self->content_type( $config->{content_type} );
delete $config->{content_type};
# Create underlying Text::CSV object
delete $config->{catalyst_component_name};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/View/ContentNegotiation/XHTML.pm view on Meta::CPAN
];
}
after process => sub {
my ($self, $c) = @_;
if ( my $accept = $self->pragmatic_accept($c) and $c->response->headers->{'content-type'} =~ m|text/html|) {
my $headers = $c->request->headers->clone;
$headers->header('Accept' => $accept);
if ( choose($self->variants, $headers) eq 'xhtml') {
$c->response->headers->{'content-type'} =~ s|text/html|application/xhtml+xml|;
}
}
$c->response->headers->push_header(Vary => 'Accept');
};
view all matches for this distribution
view release on metacpan or search on metacpan
- Better structure of the code so that ::Template can also handle
plain text views
- Added onto troubleshooting
0.11 2008-07-04 09:14:00
- Fixing a bug where content-type was ignored so multipart/alternative
failed. RT #32215
0.10 2007-11-22 23:00:00
- Refactored by Alexander Hartmaier with api changes
and POD improvements
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/View/HTML/Zoom.pm view on Meta::CPAN
Optionally set the filename extension of your zoomable templates. Common
values might be C<html> or C<xhtml>. Should be a scalar.
=head2 content_type
Sets the default C<content-type> of the response body. Should be a scalar.
=head2 root
Used at the prefix path for where yout templates are stored. Defaults to
C<< $c->config->{root} >>. Should be a scalar.
view all matches for this distribution
view release on metacpan or search on metacpan
t/content_type.t view on Meta::CPAN
use_ok('Catalyst::Test', 'TestApp');
my $response = request('/test');
ok($response->is_success, 'request ok');
is($response->header('content-type'), 'text/html; charset=utf-8', 'default content type ok');
$response = request('/test_content_type');
ok($response->is_success, 'request ok');
is($response->header('content-type'), 'text/html; charset=iso8859-1', 'content type ok');
view all matches for this distribution