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
t/70-finalize.t view on Meta::CPAN
{
Catalyst::Seal::Finalize::_clear();
my $plain = res('ct=text/plain&kind=wide');
my $latin = res('ct=text/plain%3B%20charset=ISO-8859-1&kind=wide');
is($plain->{headers}{'content-type'}, 'text/plain; charset=UTF-8',
'no charset: encoded and the charset appended');
is($latin->{headers}{'content-type'}, 'text/plain; charset=ISO-8859-1',
'a manual charset is left alone, after the plain one was cached');
Catalyst::Seal::Finalize::_clear();
my $latin2 = res('ct=text/plain%3B%20charset=ISO-8859-1&kind=wide');
my $plain2 = res('ct=text/plain&kind=wide');
is($latin2->{headers}{'content-type'}, 'text/plain; charset=ISO-8859-1',
'and in the other order');
is($plain2->{headers}{'content-type'}, 'text/plain; charset=UTF-8',
'the plain one is still encoded after the manual one was cached');
isnt($latin->{body}, $plain->{body},
'the two bodies really did take different paths');
}
t/70-finalize.t view on Meta::CPAN
# ---------------------------------------------------------- the encodable set
{
Catalyst::Seal::Finalize::_clear();
is(res('ct=application/json&kind=wide')->{headers}{'content-type'},
'application/json', 'a non-encodable type is left alone');
is(res('ct=text/plain&cenc=gzip&kind=wide')->{headers}{'content-type'},
'text/plain', 'a content-encoding other than identity suppresses encoding');
is(res('ct=text/plain&cenc=identity&kind=wide')->{headers}{'content-type'},
'text/plain; charset=UTF-8', 'identity does not');
# Distinct inputs, distinct entries: a memo that collapsed them would have
# failed the assertions above, and this says so directly.
cmp_ok(Catalyst::Seal::Finalize::memo_size(), '>=', 3,
t/70-finalize.t view on Meta::CPAN
# kind=latin, because the snowman in kind=wide does not map to Latin-1 and
# the encoder dies. Stock dies the same way; that is covered in the parity
# table, and is not what this block is about.
my $l1 = res('ct=text/plain&kind=latin&encoding=ISO-8859-1');
is($utf8->{headers}{'content-type'}, 'text/plain; charset=UTF-8',
'UTF-8 encodes');
is($none->{headers}{'content-type'}, 'text/plain',
'clear_encoding suppresses encoding, after UTF-8 was cached');
is($l1->{headers}{'content-type'}, 'text/plain; charset=ISO-8859-1',
'a different encoding is not served the UTF-8 answer');
isnt($utf8->{body}, $none->{body}, 'and the bodies differ accordingly');
}
# -------------------------------------------------------------- body shapes
{
Catalyst::Seal::Finalize::_clear();
is(res('ct=text/plain&kind=array')->{headers}{'content-type'}, 'text/plain',
'an arrayref body is not encoded');
is(res('ct=text/plain&kind=fh')->{headers}{'content-type'}, 'text/plain',
'a filehandle body is not encoded');
is(res('ct=text/plain&kind=undef')->{headers}{'content-type'}, 'text/plain',
'an absent body is not encoded');
is(res('ct=text/plain&kind=ascii')->{body}, 'plain ascii',
'an ascii body survives encoding unchanged');
}
t/70-finalize.t view on Meta::CPAN
'the decision memo stopped growing at the cap');
cmp_ok(Catalyst::Seal::Finalize::capped(), '>', 0, 'and said so');
# Still correct past the cap, which is the point of capping rather than
# clearing.
is(res('ct=text/plain%3B%20charset=ISO-8859-1&kind=wide')->{headers}{'content-type'},
'text/plain; charset=ISO-8859-1', 'decisions are still right past the cap');
}
Catalyst::Seal::Finalize::_clear();
# ----------------------------------------------------------------- DESTROY
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
view release on metacpan or search on metacpan
'body' => bless( do{\(my $o = 'hi')}, 'Text::MicroTemplate::EncodedString' ),
'cookies' => {},
'finalized_headers' => 1,
'headers' => bless( {
'content-length' => 2,
'content-type' => 'text/html; charset=utf8',
'status' => '200',
'x-catalyst' => '5.80013'
}, 'HTTP::Headers' ),
'status' => '200'
}, 'Catalyst::Response' ),
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/View/MojoTemplate.pm view on Meta::CPAN
These are just pass thru to L<Mojo::Template>. See that for details
=head2 content_type
The HTTP content-type that is set in the response unless it is already set.
=head2 helpers
A hashref of helper functions. For example:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/View/PDFBoxer.pm view on Meta::CPAN
{
$Catalyst::View::PDFBoxer::VERSION = '0.001';
}
use Moose::Role;
# ABSTRACT: Runs view output through PDF::Boxer and sets response content-type if not already set.
use PDF::Boxer 0.003;
use PDF::Boxer::SpecParser;
use namespace::clean -except => 'meta';
lib/Catalyst/View/PDFBoxer.pm view on Meta::CPAN
=pod
=head1 NAME
Catalyst::View::PDFBoxer - Runs view output through PDF::Boxer and sets response content-type if not already set.
=head1 VERSION
version 0.001
lib/Catalyst/View/PDFBoxer.pm view on Meta::CPAN
=head1 DESCRIPTION
This is a Role which takes the current $c->response->body, runs it through
PDF::Boxer as it's "spec" file to get a PDF::API2 object. $c->response->body
is then set to the stringified PDF and content-type is set accordingly.
=head1 METHOD MODIFIERS
=head2 before process
Sets content-type to 'application/pdf; charset=utf-8' if not already set.
=head2 after process
Takes the current $c->response->body, runs it through PDF::Boxer as it's "spec"
file to get a PDF::API2 object. $c->response->body is then set to the
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/View/TT/ForceUTF8.pm view on Meta::CPAN
'utf-8' is set by default. See more detail L<Template::Provider::Encoding>.
=item CONTENT TYPE
When you set *STRICT_CONTENT_TYPE* configuration,
It automatically set content-type 'application/xhtml+xml; charset=utf-8'
for browsers except MSIE.
=back
=head1 SEE ALSO
view all matches for this distribution
view release on metacpan or search on metacpan
- Added POD tests and made them pass.
- updated for Catalyst 5
- New TT Helpers.
0.09 Wed Mar 29 13:47:00 2005
- Don't override user-set charset/content-type
- Cleaned up the content-type we set.
- Updated README to current POD to current POD
0.08 Wed Mar 29 12:22:00 2005
- changed order of stash so stash can override c/base/name
- fixed some typos
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/View/Template/Lace/Tutorial.pod view on Meta::CPAN
->http_ok;
}
__PACKAGE__->meta->make_immutable;
Here you can see we are calling the view and passing it the required attributes. Attributes can also come from application configuration (or even the stash, if you are using the role L<Catalyst::View::Template::Lace::Role::ArgsFromStash>). In this ...
<html>
<head>
<title>
User Info
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/View/Template/PHP.pm view on Meta::CPAN
foreach my $headerref (@{$self->{_headers}}) {
my ($header, $replace) = @$headerref;
my ($key, $value) = split /:\s+/, $header, 2;
next if lc $key eq 'content-length';
if (lc $key eq 'content-type') {
$c->response->content_type($value);
} elsif (lc $key eq 'content-encoding') {
$c->response->content_encoding($value);
} else {
if ($replace) {
lib/Catalyst/View/Template/PHP.pm view on Meta::CPAN
As with L<Catalyst::View::TT>, the contents of the stash (C<< $c->stash >>)
will be accessible in PHP as global variables.
=item C<< $HTTP_RAW_POST_DATA >>, C<< php://input >>
On POST requests where the content-type is not C<multipart/form-data>
or C<application/x-www-url-form-encoded>, the global PHP variable
C<$HTTP_RAW_POST_DATA> and the PHP input stream C<< php://input >>
will be set to contain the content of the request.
C<Catalyst::View::Template::PHP> cannot currently set up PHP's
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/View/Templated.pm view on Meta::CPAN
Called by Catalyst to render a template. Renders the template
returned by C<< $self->template >> and sets the response body to the
result of the template evaluation.
Also sets up a content-type header for text/html with the charset of
the data (utf8 if the data contains utf8 characters, iso-8859-1
otherwise).
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
Revision history for CatalystX-CRUD-Controller-REST
0.005 18 Nov 2015
- two_args_POST now defers to model to indicate support for $model->create_related
- refactor tests to set explicit content-type for PUT requests (https://rt.cpan.org/Ticket/Display.html?id=108962)
0.004 11 May 2014
- fix bug calling status_bad_request()
0.003 01 Jan 2013
view all matches for this distribution
view release on metacpan or search on metacpan
t/test3/conf.t view on Meta::CPAN
$t->queue_frame_to_receive(Net::Stomp::Frame->new({
command => 'MESSAGE',
headers => {
destination => $dest,
'content-type' => 'json',
type => $type,
'message-id' => $code,
},
body => qq{{"foo":"$dest","bar":"$type"}},
}));
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CatalystX/Controller/ExtJS/REST/SimpleExcel.pm view on Meta::CPAN
extends 'CatalystX::Controller::ExtJS::REST';
with 'CatalystX::Controller::ExtJS::REST::SimpleExcel';
1;
Access C<< /users?content-type=application%2Fvnd.ms-excel >> to get the excel file.
=head1 DESCRIPTION
This role loads L<Catalyst::Action::Serialize::SimpleExcel> and adds
C<< application/vnd.ms-excel >> to the type map. When requesting a list of
view all matches for this distribution
view release on metacpan or search on metacpan
root/static/advanced.html view on Meta::CPAN
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Uploader With DataTable Example</title>
<!-- Required YUI files -->
<link rel="stylesheet" type="text/css" href="/static/js/yui/build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="/static/js/yui/build/datatable/assets/skins/sam/datatable.css" />
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CatalystX/Action/ExtJS/Serialize.pm view on Meta::CPAN
=head1 PUBLIC METHODS
=head2 execute
Wrap the serialized response in a textarea field if there was a file upload.
Furthermore set the C<content-type> to C<< text/html >>.
=cut
=head1 AUTHOR
view all matches for this distribution
view release on metacpan or search on metacpan
1.101700 2010-06-19
- Fixed prereq
1.101670 2010-06-16
- Fixed content-type for Direct API
- Fixed prereq
1.101570 2010-06-06
- Fixed bogus bug where C::View::JSON prepends the BOM when agent = Safari
- Fixed meta to not include example/tutorial libs
view all matches for this distribution
view release on metacpan or search on metacpan
is $res->code, 300, 'HTTP 300';
$res = $cb->(GET "?id=0&format=yaml");
is $res->content, "---\nhello: world\n", 'content';
is $res->code, 200, 'HTTP 200';
is $res->header('content-type'), 'text/yaml', 'YAML';
$res = $cb->(GET "?id=abc&format=yaml");
is $res->code, 404, 'HTTP 404';
};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catmandu/Store/Resolver/API.pm view on Meta::CPAN
return decode_json($response->decoded_content);
} else {
# If it is 404, it could be that the "new" api works,
# but that the entity doesn't exist. So we check for
# the presence of the error "Entity not found"
# Also, the new API returns the application/json content-type
# while the old doesn't.
if ($response->code == 404) {
if ($response->content_type eq 'application/json') {
return {
'data' => {}
view all matches for this distribution