view release on metacpan or search on metacpan
CAB/Client/HTTP.pm view on Meta::CPAN
#$form{enc} = $form{encoding} if ($form{encoding});
$form{fmt} = $form{format} if ($form{format});
delete(@form{qw(format encoding qraw headers cacheGet cacheSet)});
delete(@form{grep {!defined($form{$_})} keys %form});
##-- content-type hacks
my $ctype = $opts->{contentType};
$ctype = 'application/octet-stream' if (!$ctype);
delete(@form{qw(q qd contentType)});
##-- compatibility check / raw vs. formatted
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dallycot/Library/Linguistics.pm view on Meta::CPAN
return $text -> resolve_content -> then(
sub {
my ($body) = @_;
my $content = '';
given ( blessed $body ) {
when ('HTML') { # content-type: text/html
# we want to strip out the HTML and keep only text in the
# <body /> outside of <script/> tags
my $dom = Mojo::DOM->new( $body->{'value'} );
$content = $dom->find('body')->all_text;
}
when ('Dallycot::Value::String') { # content-type: text/plain
$content = $body->value;
}
when ('XML') { # content-type: text/xml (TEI, etc.)
my $dom = Mojo::DOM->new->xml(1)->parse( $body->{'value'} );
$content = $dom->all_text;
}
default {
croak "Unable to extract text from " . $text->{'value'};
view all matches for this distribution
view release on metacpan or search on metacpan
public/javascripts/jQuery/jquery-1.7.2.min.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
0.0308 2016-05-26 14:08:53 CEST
- more pod and a demo application
- bugfixes
0.0307 2015-07-02 15:00:35 CEST
- put function call "content_type 'xml'" in function "render". Now errors also have content-type application/xml
0.0306 2015-03-13 09:52:27 CET
- metadata_formats cql option
- fix pod
- more tests
view all matches for this distribution
view release on metacpan or search on metacpan
share/debugtoolbar/js/jquery.min.js view on Meta::CPAN
* Copyright 2011, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
*
* Date: Thu May 12 15:04:36 2011 -0400
*/
(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!cj[a]){var b=f("<"+a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d===""){ck||(ck=c.createElement("iframe"),...
)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)...
b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!bb.test(k))k=b.createTextNode(k);else{k=k.replace($,"<$1></$2>");var l=(_.exec(k)||["",""])[1].toLowerCase(...
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/DirectoryView.pm view on Meta::CPAN
# have stolen it from rack/directory.rb. The world of open-source is full of
# thieves.
$builtin_tpl->{layout} = <<END;
<html><head>
<title>[% path %]</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">
table { width: 100%; }
.name { text-align:left; }
.size, .mtime { text-align:right; }
.type { width:11em; }
view all matches for this distribution
view release on metacpan or search on metacpan
Change: c0332a9cc1945c41f12e999c734558f4fe94f58d
Author: unknown <Administrator@.(none)>
Date : 2010-09-10 20:20:33 +0000
fixed smtp authentication support, added reply_to, default
content-type is text
Change: d135fa031b9010e21bf568d58a5c1ef8e3893361
Author: Al Newkirk & Associates <github@alnewkirk.com>
Date : 2010-09-10 15:43:26 +0000
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Preprocess/Less.pm view on Meta::CPAN
open(my $f, '>', $css_file_abs);
print {$f} $css;
close($f);
}
header 'content-type' => 'text/css';
return $css;
}
else {
# Check if the CSS file exists. Probably not, because if it does exist,
# then Dancer should have already served it as a static file, and we
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Preprocess/Sass.pm view on Meta::CPAN
open(my $f, '>', $css_file_abs);
print {$f} $css;
close($f);
}
header 'content-type' => 'text/css';
return $css;
}
else {
# Check if the CSS file exists. Probably not, because if it does exist,
# then Dancer should have already served it as a static file, and we
view all matches for this distribution
view release on metacpan or search on metacpan
t/two-posts.t view on Meta::CPAN
use Dancer::Test;
use HTTP::Headers;
my $head = HTTP::Headers->new;
$head->header("content-type" => "application/json");
for ( 1..2 ) {
my $resp = dancer_response( 'POST' => '/foo.json', {
body => '{"yin":"yang","foo":"bar"}',
headers => $head,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/RESTModel.pm view on Meta::CPAN
=item * data - The data structure to send (hashref, arrayref). The data will
be encoded according to the value of the I<type> attribute
=item * args - B<optional> hashref with arguments to augment the way the call
is handled. It currently provides the 'deserializer' key to change the
deserializer if you I<know> that the response's content-type is incorrect,
and also the 'preserve_headers' which, if set to true, will keep the headers
between calls:
my $res = model('MyData')->post(
'users/123',
view all matches for this distribution
view release on metacpan or search on metacpan
t/125-restish.t view on Meta::CPAN
"get_all_persons()"
) or diag(explain($response3->{content}));
}
{ # test with non JSON body (no content-type)
my $response = dancer_response(
POST => '/db/person',
{
headers => [ Origin => 'http://localhost' ],
body => to_json(
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/RPCPlugin/DefaultRoute.pm view on Meta::CPAN
=head3 Responses
All responeses will have B<status: 200 OK>
The B<content-type> (and B<body>) of the request determine the error-response:
=over
=item B<text/xml>
lib/Dancer/RPCPlugin/DefaultRoute.pm view on Meta::CPAN
'error': {
'code': -32601,
'message': "Method '$request->path' not found"
}
=item B<other/content-type>
Any other content-type is outside the scope of the service. We can respond in
any way we like. For the moment it will be:
status(404)
content_type('text/plain')
body => "Error! '$request->path' was not found for '$request->content_type'"
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Swagger.pm view on Meta::CPAN
},
get '/judge/:judge_name' => { ... };
If the key C<example> is given (instead of C<examples> as defined by the Swagger specs),
and the serializer used by the application is L<Dancer::Serializer::JSON> or L<Dancer::Serializer::YAML>,
the example will be expanded to have the right content-type key.
swagger_path {
responses => {
default => { example => { fullname => 'Mary Ann Murphy' } }
},
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Tapir.pm view on Meta::CPAN
else {
$status ||= 500;
$response = $json_xs->encode({ $result_key => $result_value });
}
header 'content-type' => 'application/json';
status $status;
return $response;
};
my $wrapper_sub = sub {
lib/Dancer/Plugin/Tapir.pm view on Meta::CPAN
}
else {
$logger->error("$ex");
$result = $json_xs->encode({ exception => "$ex" });
}
header 'content-type' => 'application/json';
status $status;
};
# Returning the result will print it to the HTTP response
return $result;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Thumbnail.pm view on Meta::CPAN
if ( ( header('If-Modified-Since') || '' ) eq $lmod ) {
status 304;
return;
}
# target format & content-type
my $mime = Dancer::MIME->instance;
my $fmt = $opts->{ format } || $conf->{ format } || 'auto';
my $type = $fmt eq 'auto' ?
$mime->for_file( $file ) :
$mime->for_name( $fmt )
view all matches for this distribution
view release on metacpan or search on metacpan
bin/index-ical.pl view on Meta::CPAN
index => $full_name,
type => 'file', # or 'attachment' ?!
#id => $msg->messageid,
id => $msg->{uid},
# index bcc, cc, to, from
# content-type, ...
body => { # "body" for non-bulk, "source" for bulk ...
#source => {
url => $msg->{url},
title => $msg->{summary} . "($calendar_def->{name})",
title_suggest => $msg->{title_suggest}, # ugh
view all matches for this distribution
view release on metacpan or search on metacpan
t/apps/Foo/public/javascripts/jquery.js view on Meta::CPAN
false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&...
false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);r...
c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._...
d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var ...
g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f)...
1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){...
"json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n===...
if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","padd...
this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(la[d])f=la[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;f...
"olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&c.isFunction(b))this._toggle.apply(this,arguments)...
animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var j=c.extend({},e),i,o=this.nodeType===1&&c(this).is(":hidden"),k=this;for(i in a){var n=i.repl...
view all matches for this distribution
view release on metacpan or search on metacpan
t/apps/Foo/public/javascripts/jquery.js view on Meta::CPAN
false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&...
false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);r...
c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._...
d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var ...
g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f)...
1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){...
"json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n===...
if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","padd...
this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(la[d])f=la[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;f...
"olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&c.isFunction(b))this._toggle.apply(this,arguments)...
animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var j=c.extend({},e),i,o=this.nodeType===1&&c(this).is(":hidden"),k=this;for(i in a){var n=i.repl...
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer.pm view on Meta::CPAN
return "This is " . config->{appname};
};
=head2 content_type
Sets the B<content-type> rendered, for the current route handler:
get '/cat/:txtfile' => sub {
content_type 'text/plain';
# here we can dump the contents of param('txtfile')
lib/Dancer.pm view on Meta::CPAN
content_type 'svg';
# here we can dump the image with id param('id')
};
Note that if you want to change the default content-type for every route, you
have to change the C<content_type> setting instead.
=head2 dance
Alias for the C<start> keyword.
lib/Dancer.pm view on Meta::CPAN
streaming => 1,
bytes => 524288, # 512K
);
};
The content-type will be set depending on the current MIME types definition
(see C<mime> if you want to define your own).
If your filename does not have an extension, or you need to force a
specific mime type, you can pass it to C<send_file> as follows:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/Ajax.pm view on Meta::CPAN
# ...
}
=head1 CONFIGURATION
By default the plugin will use a content-type of 'text/xml', but this can be overridden
with the plugin setting C<content_type>.
Here is an example to use JSON:
plugins:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/CSRFI.pm view on Meta::CPAN
If provided, template token with csrf token will be set.
=head3 validate_post
If true, token will be automatically validates each post request with
content-types application/x-www-form-urlencoded or multipart/form-data.
=head3 field_name
Filed name in body-parameters sent with post request, where this module will try
to find csrf token, when validate_post is enabled.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/DoFile.pm view on Meta::CPAN
}
}
}
if (defined $result && ref $result eq 'HASH') {
$result->{'content-type'} = $acceptext->{$fmt};
$stash->{dofiles}->{$cururl.$m.$acceptext->{$fmt}.$ext}->{last} = 1;
return $result;
} elsif (ref $result eq 'ARRAY') {
$stash->{dofiles}->{$cururl.$m.$acceptext->{$fmt}.$ext}->{last} = 1;
return { 'content-type' => $acceptext->{$fmt}, content => $result };
} elsif (!ref $result && $result) {
# do we assume this is HTML? Or a file to use in templating? Who knows!
$stash->{dofiles}->{$cururl.$m.$acceptext->{$fmt}.$ext}->{last} = 1;
return { 'content-type' => $acceptext->{$fmt}, content => $result };
}
}
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/HTTP/Bundle.pm view on Meta::CPAN
use Dancer2::Plugin::HTTP:::Bundle
get '/secrets/:id' => http_auth_handler_can('find_something') => sub {
# what content-type does the client want
http_choose_accept (
[ 'application/json', 'application/xml' ] => sub {
# find the resource
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/LogReport.pod view on Meta::CPAN
}, {
content_type => 'application/json; charset=UTF-8',
});
};
» example: Return JSON responses for requests with content-type of application/json
fatal_handler sub {
my ($dsl, $msg, $reason, $default) = @_;
(my $ctype = $dsl->request->header('content-type')) =~ s/;.*//;
return if $ctype ne 'application/json';
status $reason eq 'PANIC' ? 'Internal Server Error' : 'Bad Request';
$dsl->send_as(JSON => {
error => 1,
description => $msg->toString,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/OpenAPI.pm view on Meta::CPAN
get '/judge/:judge_name' => { ... };
If the key C<example> is given (instead of C<examples> as defined by the OpenAPI specs),
and the serializer used by the application is L<Dancer2::Serializer::JSON> or L<Dancer2::Serializer::YAML>,
the example will be expanded to have the right content-type key.
openapi_path {
responses => {
default => { example => { fullname => 'Mary Ann Murphy' } }
},
view all matches for this distribution
view release on metacpan or search on metacpan
t/125-restish.t view on Meta::CPAN
"get_all_persons()"
) or diag(explain($response3->content));
}
{ # test with non JSON body (no content-type)
my $response = $tester->request(
HTTP::Request->new(
POST => '/db/person',
[ Origin => 'http://localhost' ],
to_json(
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/RPCPlugin/DefaultRoute.pm view on Meta::CPAN
=head3 Responses
All responeses will have B<status: 200 OK>
The B<content-type> (and B<body>) of the request determine the error-response:
=over
=item B<text/xml>
lib/Dancer2/RPCPlugin/DefaultRoute.pm view on Meta::CPAN
'error': {
'code': -32601,
'message': "Method '$request->path' not found"
}
=item B<other/content-type>
Any other content-type is outside the scope of the service. We can respond in
any way we like. For the moment it will be:
status(404)
content_type('text/plain')
body => "Error! '$request->path' was not found for '$request->content_type'"
view all matches for this distribution
view release on metacpan or search on metacpan
t/Dancer2-Serializer-XML.t view on Meta::CPAN
# Test 5: check content type is right
is(
$serializer->content_type,
'application/xml',
'content-type is set correctly',
);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Core/Response.pm view on Meta::CPAN
=head2 serialize( $content )
$response->serialize( $content );
Serialize and return $content with the response's serializer.
set content-type accordingly.
=head2 header($name)
Return the value of the given header, if present. If the header has multiple
values, returns the list of values if called in list context, the first one
view all matches for this distribution