view release on metacpan or search on metacpan
lib/Limper/SendFile.pm view on Meta::CPAN
my $date = parse_date("Sunday, 06-Nov-94 08:49:37 GMT");
my $date = parse_date("Sun Nov 6 08:49:37 1994");
=head2 mime_types
Returns a B<HASH> of file extension / content-type pairs.
=head1 HOOKS
=head2 after
view all matches for this distribution
view release on metacpan or search on metacpan
docs/DetectLanguage.pl view on Meta::CPAN
#!/usr/bin/perl -w
require "Languages.inc"; # ïîëó÷èëè @AvailableLangs
my $AcceptLang=$ENV{HTTP_ACCEPT_LANGUAGE};
#print "content-type: text/html\n\n";
if ( $AcceptLang ) { # Åñëè ïåðåìåííàÿ HTTP-ACCEPT-LANGUAGE îò áðàóçåðà ïîëó÷åíà
# Ïåðåáèðàåì ñïèñîê @AvailableLangs è âûõîäèì, êàê òîëüêî íàòêíåìñÿ íà íóæíûé ÿçûê
for ( @{$AvailableLangs} ) {
if ($AcceptLang=~/$_/ ) { $DefaultLang=$_; last;}
view all matches for this distribution
view release on metacpan or search on metacpan
js/jquery/jquery-1.4.js view on Meta::CPAN
// Opera returns 0 when status is 304
return xhr.status === 304 || xhr.status === 0;
},
httpData: function( xhr, type, s ) {
var ct = xhr.getResponseHeader("content-type") || "",
xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
data = xml ? xhr.responseXML : xhr.responseText;
if ( xml && data.documentElement.nodeName === "parsererror" ) {
throw "parsererror";
view all matches for this distribution
view release on metacpan or search on metacpan
loadworm.pl view on Meta::CPAN
return;
}
print "\n";
# We are done here, unless it is an HTML document . . .
unless ( ${$response}{'_headers'}{'_header'}{'content-type'}[0] eq "text/html" )
{print TIMING "\n"; return;}
# . . . then we must parse it, too.
($base, $html) = &ParseFile($response);
# I think that URI::URL::url() handles "func?..." wrong. It does not belong with the $BASE, so . . .
loadworm.pl view on Meta::CPAN
# $yyy = "";
# for $yy ( @y) { $yyy .= $yy.","; }
# chop $yyy;
# print "$_=".$yyy."\n";
# }
print ${$response}{'_headers'}{'_header'}{'content-type'}[0]."\n";
}
# Skip certain documents, well, just because!
view all matches for this distribution
view release on metacpan or search on metacpan
t/demo.po.pl view on Meta::CPAN
$VAR1 = [
{
'headers' => {
'last-translator' => 'Thomas Thurman <marnanel@cpan.org>',
'content-type' => 'text/plain; charset=UTF-8',
'language-team' => 'test <test@example.org>',
'po-revision-date' => '1975-01-30 00:00 +0000',
'mime-version' => '1.0',
'project-id-version' => 'Demo of a .po file',
'content-transfer-encoding' => '8bit'
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Log/Dispatch/Email/Siffra.pm view on Meta::CPAN
Subject => $subject,
Data => $message,
Type => 'text/html; charset=UTF-8',
);
$msg->attr( 'content-type' => 'text/html' );
$msg->attr( 'content-type.charset' => 'UTF-8' );
$msg->send( 'smtp', $host, 'port', $port );
$log->info( "Email enviado com sucesso : host [ $host ] port [ $port ] subject [ $subject ]\n" );
} ## end sub send_email
=head3 C<flush()>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Log/Report/Lexicon/MOTcompact.pm view on Meta::CPAN
unless(defined $charset)
{ $msgid_b eq ''
or error __x"the header is not the first entry, needed for charset in {fn}", fn => $fn;
$charset = $msgstr_b =~ m/^content-type:.*?charset=["']?([\w-]+)/mi
? $1 : error __x"cannot detect charset in {fn}", fn => $fn;
trace "auto-detected charset $charset for $fn";
$enc = find_encoding($charset)
or error __x"unsupported charset {charset} in {fn}"
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
sample/us_constitution/index.html view on Meta::CPAN
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<link rel="stylesheet" type="text/css" href="uscon.css">
<title>US Constitution</title>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
view all matches for this distribution
view release on metacpan or search on metacpan
contrib/mhn2mbox.pl view on Meta::CPAN
print MBOXFILE "Message-ID: <$href->{'message-id'}[0]>\n";
}
print MBOXFILE "MIME-Version: 1.0\n";
if (defined($href->{'content-type'})) {
$contype = $href->{'content-type'}[0];
} elsif (defined($href->{'contenttype'})) { # older versions
$contype = $href->{'contenttype'}[0];
}
if (defined($href->{'msgbodytext'})) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MIME/BodyMunger.pm view on Meta::CPAN
my ($self, $entity, $code) = @_;
Carp::confess "rewrite_content called on non-text part"
unless $entity->effective_type =~ qr{\Atext/(?:html|plain)(?:$|;)}i;
my $charset = $entity->head->mime_attr('content-type.charset')
|| 'ISO-8859-1';
$charset = 'MacRoman' if lc $charset eq 'macintosh';
Carp::carp(qq{rewriting message in unknown charset "$charset"})
lib/MIME/BodyMunger.pm view on Meta::CPAN
my ($self, $entity, $code) = @_;
Carp::confess "rewrite_lines called on non-text part"
unless $entity->effective_type =~ qr{\Atext/(?:html|plain)(?:$|;)}i;
my $charset = $entity->head->mime_attr('content-type.charset')
|| 'ISO-8859-1';
$charset = 'MacRoman' if lc $charset eq 'macintosh';
Carp::carp(qq{rewriting message in unknown charset "$charset"})
view all matches for this distribution
view release on metacpan or search on metacpan
share/mime-info/freedesktop.org.xml view on Meta::CPAN
<match type="string" value="BSDIFN40" offset="0"/>
</magic>
<glob pattern="*.bsdiff"/>
</mime-type>
<!-- Tree content-types -->
<mime-type type="x-content/image-dcf">
<!-- http://en.wikipedia.org/wiki/Design_rule_for_Camera_File_system -->
<comment>Digital photos</comment>
<treemagic>
<treematch path="dcim" type="directory" non-empty="true"/>
view all matches for this distribution
view release on metacpan or search on metacpan
t/10_expander.t view on Meta::CPAN
is( MIME::Expander->regulate_type('text/plain'), 'text/plain', 'regulate_type normal');
is( MIME::Expander->regulate_type('text/x-me'), 'text/me', 'regulate_type unregistered');
is( MIME::Expander->regulate_type('x-media/x-type'), 'media/type', 'regulate_type unregistered');
is( MIME::Expander->regulate_type(), undef, 'regulate_type undef');
is( MIME::Expander->regulate_type('a'), undef, 'regulate_type invalid');
is( MIME::Expander->regulate_type('text/plain; charset=UTF-8'), 'text/plain', 'regulate_type content-type');
}
# regulate_type (via instance)
{;
t/10_expander.t view on Meta::CPAN
is( $me->regulate_type('text/plain'), 'text/plain', 'regulate_type normal');
is( $me->regulate_type('text/x-me'), 'text/me', 'regulate_type unregistered');
is( $me->regulate_type('x-media/x-type'), 'media/type', 'regulate_type unregistered');
is( $me->regulate_type(), undef, 'regulate_type undef');
is( $me->regulate_type('a'), undef, 'regulate_type invalid');
is( $me->regulate_type('text/plain; charset=UTF-8'), 'text/plain', 'regulate_type content-type');
}
# walk
# => 11_expander_walk.t
view all matches for this distribution
view release on metacpan or search on metacpan
$VERSION = '0.39';
use constant BUFFSIZE => 64;
my %h_hash = (
'content-type' => "",
'content-disposition' => "",
'content-transfer-encoding' => "",
);
my @patterns = (
}
next;
}
next if(!$checkhdr && (length() <= 2) && /$patterns[2]/o);
$header = 0;
if(exists($_[0]->{$tree}->{'content-type'}) && exists($_[0]->{$tree}->{'content-type'}->{value})) {
$_[0]->{$tree}->{'content-type'}->{value} = lc($_[0]->{$tree}->{'content-type'}->{value});
if(exists($_[0]->{$tree}->{'content-type'}->{boundary}) && $_[0]->{$tree}->{'content-type'}->{value} =~ /multipart\/\w+/o) {
my $res = &_parse($fhs, $header, $mbox, $tree, $_[0]->{$tree}->{'content-type'}->{boundary}, $args, $files, $_[0]);
if($res->[1]) {
$mbox ? ($tmp = 1) : return([$tree, $res->[1]]);
$_ = $res->[1];
} else { next; }
} elsif($_[0]->{$tree}->{'content-type'}->{value} eq "message/rfc822") {
my $res = &_parse($fhs, 1, $mbox, $tree, $origin, $args, $files, $_[0]);
if($res->[1]) {
$mbox ? ($tmp = 1) : return([$tree, $res->[1]]);
$_ = $res->[1];
} else { next; }
{
action => $args->{'types_action'},
mimetypes => $args->{'ctypes'}
}
);
$_[0]->{"$tree.$attcount"}->{'content-type'}->{value} = $res->[0];
$_[0]->{"$tree.$attcount"}->{'content-disposition'}->{filepath} = $filepath unless($res->[1]);
$attcount++;
next;
}
my $breakmsg = "";
unless(defined($fh)) {
$boundary = $origin;
if(exists($_[0]->{$tree}->{'content-type'}) && exists($_[0]->{$tree}->{'content-type'}->{value})) {
$exclude = 1 if(($_[0]->{$tree}->{'content-type'}->{value} =~ /^multipart\/\w+$/o) || ($_[0]->{$tree}->{'content-type'}->{value} eq "message/rfc822"));
} else { $check_ctype = 1; }
unless($exclude) {
if(exists($_[0]->{$tree}->{'content-transfer-encoding'}) &&
exists($_[0]->{$tree}->{'content-transfer-encoding'}->{value})) {
$_[0]->{$tree}->{'content-transfer-encoding'}->{value} = lc($_[0]->{$tree}->{'content-transfer-encoding'}->{value});
my $res = &decode_content($fhs,
$_[0]->{$tree}->{'content-transfer-encoding'}->{value},
$filepath,
$boundary ? "--$boundary" : "",
{
mimetype => $_[0]->{$tree}->{'content-type'}->{value} || "",
checktype => $args->{'check_ctype'},
action => $args->{'types_action'},
mimetypes => $args->{'ctypes'},
mailbox => $mbox
});
$_[0]->{$tree}->{'content-type'}->{value} = $res->[1] if($res->[1]);
$_[0]->{$tree}->{'content-disposition'}->{filepath} = $filepath unless($res->[2]);
$tmp = 1;
unless($_ = $res->[0]) {
$exclude = 1;
next;
if(index($_, "--$boundary") >= 0) {
defined($fh) and &file_close($fh);
($tmp, $header) = (1, 1);
$boundary = "";
if($ph) {
return([$tree]) if($_[0]->{$base}->{'content-type'}->{value} eq "message/rfc822");
my @ps = split(/\./o, $tree);
$ps[$#ps]++;
$tree = join("\.", @ps);
}
next;
}
(!$exclude && $ph) or next;
if($check_ctype && $args->{check_ctype}) {
($tmpbuff .= $_) =~ s/^[\n\r\t]+//o;
if(length($tmpbuff) > BUFFSIZE) {
$_[0]->{$tree}->{'content-type'}->{value} ||= "";
if(my $ct = set_content_type($tmpbuff, $_[0]->{$tree}->{'content-type'}->{value})) {
$_[0]->{$tree}->{'content-type'}->{value} = $ct;
$tmpbuff = "";
$check_ctype = 0;
}
if($exclude = exists($args->{'ctypes'}->{$_[0]->{$tree}->{'content-type'}->{value}}) ? ($args->{'types_action'} ? 0 : 1) :
scalar(keys(%{$args->{'ctypes'}})) ? ($args->{'types_action'} ? 1 : 0) : ($args->{'types_action'} ? 0 : 1)) {
if(defined($fh)) {
&file_close($fh);
unlink($_[0]->{$tree}->{'content-disposition'}->{filepath});
delete($_[0]->{$tree}->{'content-disposition'}->{filepath});
my $h = shift;
my $file = "file";
if(exists($h->{'content-disposition'}->{filename})) {
$file = $h->{'content-disposition'}->{filename};
} elsif(exists($h->{'content-type'}->{name})) {
$file = $h->{'content-type'}->{name};
} elsif(exists($h->{'content-type'}->{value})) {
my $ctype = lc($h->{'content-type'}->{value});
$file .= $content_type{$ctype} || "";
}
$file =~ s/^[ \.]+$/file/o;
$h->{'content-disposition'}->{filename} = &check_filename($files, $file);
$h->{'content-transfer-encoding'}->{value} = "" unless(exists($h->{'content-transfer-encoding'}->{value}));
If the value is set to octal number then make the output_dir directory
(example: mkdir => 0755).
=item check_content_type => 0 or 1
If the value is set to 1 the content-type of file is checked
=item decode_subject => 0 or 1
If the value is set to 1 then the subject is decoded into a list.
view all matches for this distribution
view release on metacpan or search on metacpan
=item I<new> ()
=item I<new> (subtype = "mixed")
Class method.
Creates a new MIME::Fast::MultiPart object with a default content-type of
multipart/mixed.
=item I<set_preface> (text)
=item I<get_preface> ()
=item I<set_content_type_parameter> ($name, $value)
=item I<get_content_type_parameter> ($name)
Sets or gets the value of the content-type param $name set on the MIME part object.
=item I<set_content_id> (content_id)
=item I<get_content_id> ()
=over 4
=item I<new> (subtype = "rfc822" [, message])
Creates a new MIME message part object with a default content-type
of message/$subtype (optionally containing $message object).
=item I<set_message> (message)
=item I<get_message> ()
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MIME/Lite/Generator.pm view on Meta::CPAN
my $sub_attrs = $self->{msg}{SubAttrs};
my $rv;
$self->{state} = 'first';
### Output either the body or the parts.
### Notice that we key off of the content-type! We expect fewer
### accidents that way, since the syntax will always match the MIME type.
my $type = $attrs->{'content-type'};
if ( $type =~ m{^multipart/}i ) {
$self->{boundary} = $sub_attrs->{'content-type'}{'boundary'};
### Preamble:
$rv = \($self->{msg}->header_as_string . "\n" . (
defined( $self->{msg}{Preamble} )
? $self->{msg}{Preamble}
view all matches for this distribution
view release on metacpan or search on metacpan
my $ref = ($txt || @$ref_mail) ? {} : $self->{_param};
$part = new MIME::Lite(%$ref,
'Type' => 'TEXT',
'Encoding' => $self->{_htmlencoding},
'Data' => $html);
$part->attr("content-type"=> "text/html; charset=".$self->{_htmlcharset});
# Remove some header for Eudora client in HTML and related part
$part->replace("MIME-Version" => "");
$part->replace('X-Mailer' =>"");
$part->replace('Content-Disposition' =>"");
# only html, no images & no txt
my $ref = ($html ? {} : $self->{_param} );
$txt_part = new MIME::Lite (%$ref,
'Type' => 'TEXT',
'Data' => $txt,
'Encoding' => $self->{_textencoding});
$txt_part->attr("content-type" =>
"text/plain; charset=".$self->{_textcharset});
# Remove some header for Eudora client
$txt_part->replace("MIME-Version" => "");
$txt_part->replace("X-Mailer" => "");
$txt_part->replace("Content-Disposition" => "");
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MIME/Lite.pm view on Meta::CPAN
$part = MIME::Lite->new(
Top => 0,
Type =>'text/html',
Data =>'<H1>Hello</H1>',
);
$part->attr('content-type.charset' => 'UTF-8');
$part->add('X-Comment' => 'A message for you');
### Attach it to any message:
$msg->attach($part);
lib/MIME/Lite.pm view on Meta::CPAN
method assumes that you are giving in the pairs of a PARAMHASH
which will be sent into C<new()> to create the new part.
One of the possibly-quite-useful hacks thrown into this is the
"attach-to-singlepart" hack: if you attempt to attach a part (let's
call it "part 1") to a message that doesn't have a content-type
of "multipart" or "message", the following happens:
=over 4
=item *
lib/MIME/Lite.pm view on Meta::CPAN
### Create new part, if necessary:
my $part1 = ( ( @_ == 1 ) ? shift: ref($self)->new( Top => 0, @_ ) );
### Do the "attach-to-singlepart" hack:
if ( $attrs->{'content-type'} !~ m{^(multipart|message)/}i ) {
### Create part zero:
my $part0 = ref($self)->new;
### Cut MIME stuff from self, and paste into part zero:
lib/MIME/Lite.pm view on Meta::CPAN
$part0->top_level(0); ### clear top-level attributes
### Make self a top-level multipart:
$attrs = $self->{Attrs} ||= {}; ### reset (sam: bug? this doesn't reset anything since Attrs is already a hash-ref)
$sub_attrs = $self->{SubAttrs} ||= {}; ### reset
$attrs->{'content-type'} = 'multipart/mixed';
$sub_attrs->{'content-type'}{'boundary'} = gen_boundary();
$attrs->{'content-transfer-encoding'} = '7bit';
$self->top_level(1); ### activate top-level attributes
### Add part 0:
push @{ $self->{Parts} }, $part0;
lib/MIME/Lite.pm view on Meta::CPAN
### CONTENT-TYPE....
###
### Get content-type or content-type-macro:
my $type = ( $params{Type} || ( $AUTO_CONTENT_TYPE ? 'AUTO' : 'TEXT' ) );
### Interpret content-type-macros:
if ( $type eq 'TEXT' ) { $type = 'text/plain'; }
elsif ( $type eq 'HTML' ) { $type = 'text/html'; }
elsif ( $type eq 'BINARY' ) { $type = 'application/octet-stream' }
elsif ( $type eq 'AUTO' ) { $type = $self->suggest_type( $params{Path} ); }
### We now have a content-type; set it:
$type = lc($type);
my $attrs = $self->{Attrs};
my $sub_attrs = $self->{SubAttrs};
$attrs->{'content-type'} = $type;
### Get some basic attributes from the content type:
my $is_multipart = ( $type =~ m{^(multipart)/}i );
### Add in the multipart boundary:
if ($is_multipart) {
my $boundary = gen_boundary();
$sub_attrs->{'content-type'}{'boundary'} = $boundary;
}
### CONTENT-ID...
###
lib/MIME/Lite.pm view on Meta::CPAN
I<Instance method.>
Set MIME attribute ATTR to the string VALUE.
ATTR is converted to all-lowercase.
This method is normally used to set/get MIME attributes:
$msg->attr("content-type" => "text/html");
$msg->attr("content-type.charset" => "US-ASCII");
$msg->attr("content-type.name" => "homepage.html");
This would cause the final output to look something like this:
Content-type: text/html; charset=US-ASCII; name="homepage.html"
lib/MIME/Lite.pm view on Meta::CPAN
Giving VALUE as undefined will cause the contents of the named
subfield to be deleted.
Supplying no VALUE argument just returns the attribute's value:
$type = $msg->attr("content-type"); ### returns "text/html"
$name = $msg->attr("content-type.name"); ### returns "homepage.html"
=cut
sub attr {
lib/MIME/Lite.pm view on Meta::CPAN
=item field_order FIELD,...FIELD
I<Class/instance method.>
Change the order in which header fields are output for this object:
$msg->field_order('from', 'to', 'content-type', 'subject');
When used as a class method, changes the default settings for
all objects:
MIME::Lite->field_order('from', 'to', 'content-type', 'subject');
Case does not matter: all field names will be coerced to lowercase.
In either case, supply the empty array to restore the default ordering.
=cut
lib/MIME/Lite.pm view on Meta::CPAN
sub filename {
my ( $self, $filename ) = @_;
my $sub_attrs = $self->{SubAttrs};
if ( @_ > 1 ) {
$sub_attrs->{'content-type'}{'name'} = $filename;
$sub_attrs->{'content-disposition'}{'filename'} = $filename;
}
return $sub_attrs->{'content-disposition'}{'filename'};
}
lib/MIME/Lite.pm view on Meta::CPAN
# and given the performance cost of calculating it from a file handle,
# I thought it might make more sense to add some sort of computelength
# property. If computelength is false, then the length simply isn't
# computed. What do you think?
#
# Eryq's reply: I agree; for now, we can silently leave out the content-type.
sub get_length {
my $self = shift;
my $attrs = $self->{Attrs};
my $is_multipart = ( $attrs->{'content-type'} =~ m{^multipart/}i );
my $enc = lc( $attrs->{'content-transfer-encoding'} || 'binary' );
my $length;
if ( !$is_multipart && ( $enc eq "binary" ) ) { ### might figure it out cheap:
if ( defined( $self->{Data} ) ) { ### it's in core
$length = length( $self->{Data} );
lib/MIME/Lite.pm view on Meta::CPAN
if ( !@a ) { ### guess
### Scrub length always:
$self->replace( 'content-length', '' );
### Scrub disposition if no filename, or if content-type has same info:
if ( !$self->_safe_attr('content-disposition.filename')
|| $self->_safe_attr('content-type.name') )
{
$self->replace( 'content-disposition', '' );
}
### Scrub encoding if effectively unencoded:
if ( $self->_safe_attr('content-transfer-encoding') =~ /^(7bit|8bit|binary)$/i ) {
$self->replace( 'content-transfer-encoding', '' );
}
### Scrub charset if US-ASCII:
if ( $self->_safe_attr('content-type.charset') =~ /^(us-ascii)/i ) {
$self->attr( 'content-type.charset' => undef );
}
### TBD: this is not really right for message/digest:
if ( ( keys %{ $self->{Attrs}{'content-type'} } == 1 )
and ( $self->_safe_attr('content-type') eq 'text/plain' ) )
{
$self->replace( 'content-type', '' );
}
} elsif ( $expl and ( ref($expl) eq 'ARRAY' ) ) {
foreach ( @{$expl} ) { $self->replace( $_, '' ); }
}
lib/MIME/Lite.pm view on Meta::CPAN
sub binmode {
my $self = shift;
$self->{Binmode} = shift if (@_); ### argument? set override
return ( defined( $self->{Binmode} )
? $self->{Binmode}
: ( $self->{Attrs}{"content-type"} !~ m{^(text|message)/}i )
);
}
#------------------------------
lib/MIME/Lite.pm view on Meta::CPAN
#------------------------------
#
# =item suggest_type PATH
#
# I<Class/instance method.>
# Suggest the content-type for this attached path.
# We always fall back to "application/octet-stream" if no good guess
# can be made, so don't use this if you don't mean it!
#
sub suggest_type {
my ( $self, $path ) = @_;
lib/MIME/Lite.pm view on Meta::CPAN
### Coerce into a printable output handle:
$out = MIME::Lite::IO_Handle->wrap($out);
### Output either the body or the parts.
### Notice that we key off of the content-type! We expect fewer
### accidents that way, since the syntax will always match the MIME type.
my $type = $attrs->{'content-type'};
if ( $type =~ m{^multipart/}i ) {
my $boundary = $sub_attrs->{'content-type'}{'boundary'};
### Preamble:
$out->print( defined( $self->{Preamble} )
? $self->{Preamble}
: "This is a multi-part message in MIME format.\n"
lib/MIME/Lite.pm view on Meta::CPAN
=over 4
=item Content-type
You can safely scrub the "content-type" attribute if, and only if,
the part is of type "text/plain" with charset "us-ascii".
=item Content-transfer-encoding
You can safely scrub the "content-transfer-encoding" attribute
lib/MIME/Lite.pm view on Meta::CPAN
=item Content-disposition
You can safely scrub the "content-disposition" attribute
if you trust the mail reader to do the right thing when it decides
whether to show an attachment inline or as a link. Be aware
that scrubbing both the content-disposition and the content-type
means that there is no way to "recommend" a filename for the attachment!
B<Note:> there are reports of brain-dead MUAs out there that
do the wrong thing if you I<provide> the content-disposition.
If your attachments keep showing up inline or vice-versa,
lib/MIME/Lite.pm view on Meta::CPAN
From => 'me@myhost.com',
To => encode( 'MIME-Header', $to ),
Subject => encode( 'MIME-Header', $subject ),
Data => encode_utf8($text)
);
$msg->attr( 'content-type' => 'text/plain; charset=utf-8' );
$msg->send;
B<Note:>
=over
lib/MIME/Lite.pm view on Meta::CPAN
=item *
If, for the body of the email, you want to use a character set
other than UTF-8, then you should encode appropriately, and set the
correct C<content-type>, eg:
...
Data => encode('iso-8859-15',$text)
...
$msg->attr( 'content-type' => 'text/plain; charset=iso-8859-15' );
=item *
For the message headers, L<Encode::MIME::Header> only support UTF-8,
but most modern mail clients should be able to handle this. It is not
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MIME/Mini.pm view on Meta::CPAN
sub formail # rfc2822 + mboxrd format (see http://www.qmail.org/man/man5/mbox.html)
{
sub mime # rfc2045, rfc2046
{
my ($mail, $parent) = @_;
return $mail unless exists $mail->{header} && exists $mail->{header}->{'content-type'} || defined $parent && exists $parent->{mime_type} && $parent->{mime_type} =~ /^multipart\/digest$/i;
my ($content_type) = (exists $mail->{header} && exists $mail->{header}->{'content-type'}) ? @{$mail->{header}->{'content-type'}} : "Content-Type: message/rfc822\n";
my ($type) = $content_type =~ /^content-type:\s*([\w\/.-]+)/i;
my $boundary = param($mail, 'content-type', 'boundary') if $type =~ /^multipart\//i;
return $mail unless defined $type && ($type =~ /^multipart\//i && $boundary || $type =~ /^message\/rfc822$/i);
($mail->{mime_boundary}) = $boundary =~ /^(.*\S)/ if $boundary;
$mail->{mime_type} = $type;
$mail->{mime_message} = mimepart(delete $mail->{body} || '', $mail), return $mail if $type =~ /^message\/(?:rfc822|external-body)$/i;
return tnef2mime(mimeparts($mail, $parent));
lib/MIME/Mini.pm view on Meta::CPAN
sub mimetype # rfc2045, rfc2046
{
my ($m, $p) = @_;
my ($e) = header($m, 'content-transfer-encoding');
return 'application/octet-stream' if defined $e && $e !~ /^(?:[78]bit|binary|quoted-printable|base64)$/i;
my ($type) = header($m, 'content-type');
return lc $1 if defined $type && $type =~ /^((?:text|image|audio|video|application|message|multipart)\/[^\s;]+)/i;
return 'message/rfc822' if !defined $type && defined $p && exists $p->{mime_type} && $p->{mime_type} =~ /^multipart\/digest/i;
return 'text/plain';
}
lib/MIME/Mini.pm view on Meta::CPAN
my $filename_counter;
sub filename # rfc2183, rfc2045?
{
my $p = shift;
my $fn = param($p, 'content-disposition', 'filename') || param($p, 'content-type', 'name') || 'attachment' . ++$filename_counter;
$fn =~ s/^.*[\\\/]//, $fn =~ tr/\x00-\x1f !"#\$%&'()*\/:;<=>?@[\\]^`{|}~\x7f/_/s;
return $fn;
}
sub body
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MIME/Signature.pm view on Meta::CPAN
our %EXPORT_TAGS = ();
sub _decoded_body {
my $entity = shift;
my $body = $entity->bodyhandle->as_string;
if ( my $charset = $entity->head->mime_attr('content-type.charset') ) {
$body = decode $charset, $body;
}
$body;
}
lib/MIME/Signature.pm view on Meta::CPAN
my ( $entity, $body ) = @_;
$body .= "\n" if $body !~ /\n\z/;
my $encoded_body;
{
my $encoding_ok;
if ( my $charset = $entity->head->mime_attr('content-type.charset') ) {
$encoding_ok = 1;
$encoded_body = encode $charset, $body,
sub { undef $encoding_ok; '' };
}
unless ($encoding_ok) {
my $head = $entity->head;
$head->mime_attr( 'Content-Type', 'text/plain' )
unless $head->mime_attr('content-type');
$head->mime_attr( 'content-type.charset' => 'UTF-8' );
$encoded_body = encode_utf8($body);
}
}
my $fh = $entity->bodyhandle->open('w') or die "Open body: $!\n";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MIME/Structure.pm view on Meta::CPAN
my $level = $entity->{'level'} = @context - 1;
if (@context > 1) {
# Current entity is $context[-1]
$parent = $entity->{'parent'} = $context[-2];
}
my ($content_type) = @{ $fields->{'content-type'} || [] };
if (!defined $content_type) {
if ($parent && "$parent->{'type'}/$parent->{'subtype'}" eq 'multipart/digest') {
$content_type = 'message/rfc822'
}
else {
lib/MIME/Structure.pm view on Meta::CPAN
Returns a string showing the structure of a message, including the content
type and offset of each entity (i.e., the message and [if it's multipart] all
of its parts, recursively). Each entity is printed in the form:
"(" content-type ":" byte-offset [ " " parts... ")"
Offsets are B<byte> offsets of the entity's header from the beginning of the
message. (If B<parse()> was called with an I<offset> parameter, this is added
to the offset of the entity's header.)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MIME/Entity.pm view on Meta::CPAN
Encoding =>"quoted-printable",
From =>'jean.luc@inria.fr',
Subject =>"C'est bon!");
Create a document for a GIF file (the description is completely optional;
note that we have to specify content-type and encoding since they're
not the default values):
$ent = MIME::Entity->build(Description => "A pretty picture",
Path => "./docs/mime-sm.gif",
Type => "image/gif",
lib/MIME/Entity.pm view on Meta::CPAN
array, etc.) If OFFSET is not given, the new part is added to the end
of the array.
I<Thanks to Jason L Tibbitts III for providing support for OFFSET.>
B<Warning:> in general, you only want to attach parts to entities
with a content-type of C<multipart/*>).
=cut
sub add_part {
my ($self, $part, $index) = @_;
lib/MIME/Entity.pm view on Meta::CPAN
=item Filename
I<Single-part entities only. Optional.>
The recommended filename. Overrides any name extracted from C<Path>.
The information is stored both the deprecated (content-type) and
preferred (content-disposition) locations. If you explicitly want to
I<avoid> a recommended filename (even when Path is used), supply this
as empty or undef.
=item Id
lib/MIME/Entity.pm view on Meta::CPAN
The default is true. (NB: look at how C<attach()> uses it.)
=item Type
I<Optional.>
The basic content-type (C<"text/plain">, etc.).
If you don't specify it, it defaults to C<"text/plain">
as per RFC 2045. I<Do yourself a favor: put it in.>
=back
lib/MIME/Entity.pm view on Meta::CPAN
### Create head:
my $head = new MIME::Head;
$self->head($head);
$head->modify(1);
### Add content-type field:
$field = new Mail::Field 'Content_type'; ### not a typo :-(
$field->type($type);
$field->charset($charset) if $charset;
$field->name($filename) if defined($filename);
$field->boundary($boundary) if defined($boundary);
$head->replace('Content-type', $field->stringify);
### Now that both body and content-type are available, we can suggest
### content-transfer-encoding (if desired);
if (!$encoding) {
$encoding = $self->suggest_encoding_lite;
}
elsif (lc($encoding) eq '-suggest') {
lib/MIME/Entity.pm view on Meta::CPAN
like C<smtpsend()> will work. Note however that if VALUE is given,
a fatal exception is thrown, since you cannot use this method to
I<set> the lines of the encoded message.
If you want the raw (unencoded) body data, use the L<bodyhandle()|/bodyhandle>
method to get and use a MIME::Body. The content-type of the entity
will tell you whether that body is best read as text (via getline())
or raw data (via read()).
=cut
lib/MIME/Entity.pm view on Meta::CPAN
C<NLINES> of the message. If found then that line and all lines after
it will be removed. If C<NLINES> is not given, a default value of 10
will be used. This would be of most use in auto-reply scripts.
For MIME entity, this method is reasonably cautious: it will only
attempt to un-sign a message with a content-type of C<text/*>.
If you send remove_sig() to a multipart entity, it will relay it to
the first part (the others usually being the "attachments").
B<Warning:> currently slurps the whole message-part into core as an
lib/MIME/Entity.pm view on Meta::CPAN
Fatal error if it can't be read.
I<As per superclass method.>
=item Force
Sign it even if the content-type isn't C<text/*>. Useful for
non-standard types like C<x-foobar>, but be careful!
I<MIME-specific; new in this subclass.>
=item Remove
lib/MIME/Entity.pm view on Meta::CPAN
I<As per superclass method.>
=back
For MIME messages, this method is reasonably cautious: it will only
attempt to sign a message with a content-type of C<text/*>, unless
C<Force> is specified.
If you send this message to a multipart entity, it will relay it to
the first part (the others usually being the "attachments").
lib/MIME/Entity.pm view on Meta::CPAN
video/*
=item *
An array of I<parts>, where each part is a MIME::Entity object.
The number of parts will only be nonzero if the content-type
is I<not> one of the "singlepart" types:
message/* (should have exactly one part)
multipart/* (should have one or more parts)
lib/MIME/Entity.pm view on Meta::CPAN
B<Mail::Internet:>
As an array of lines.
B<MIME::Entity:>
It depends on the content-type of the message.
For "container" types (C<multipart/*>, C<message/*>), we store the
contained entities as an array of "parts", accessed via the C<parts()>
method, where each part is a complete MIME::Entity.
For "singlepart" types (C<text/*>, C<image/*>, etc.), the unencoded
body data is referenced via a MIME::Body object, accessed via
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MKDoc/Apache_Cache.pm view on Meta::CPAN
$headers ||= '';
$body ||= '';
my @o = ();
# Figure out some kind of content_type
my ($content_type) = grep /^content-type\:/i, split (/\r?\n/, $headers);
$content_type ||= 'application/octet-stream';
# Gzip body if content type probably needs gzipping
# Vary: Accept-Encoding is here to tell proxies to keep a separate
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MKDoc/Core/Plugin.pm view on Meta::CPAN
=head2 $self->HTTP_Content_Type();
Returns the content-type associated with this plugin.
By default, returns "text/html; charset=UTF-8"
=cut
sub HTTP_Content_Type { "text/html; charset=UTF-8" }
view all matches for this distribution
view release on metacpan or search on metacpan
eg/cgi_search.pl view on Meta::CPAN
#$Id: cgi_search.pl,v 1.5 1999/04/26 12:14:31 maxim Exp $
# Quick and dirty cgi-script to search a website.
# (Root dir must have been indexed using html_indexer.pl)
my $dbname = '.search.db';
BEGIN { print "content-type: text/html\n\n"; }
my $query_string = $ENV{QUERY_STRING};
if ( $query_string !~ /\S/ ) {
print_search_page();
view all matches for this distribution
view release on metacpan or search on metacpan
t/03.PDU-common-fields.t
t/04.basic-rules.t
t/05.length.t
t/06.parameter-values.t
t/07.parameter.t
t/08.content-type.t
t/09.multipart.t
t/20.immediates.t
t/21.straight.t
t/pod-coverage.t
t/pod.t
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MP3/M3U/Parser/Export.pm view on Meta::CPAN
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>MP3::M3U::Parser Generated PlayList</title>
<meta name="Generator" content="MP3::M3U::Parser">
<meta http-equiv="content-type"
content="text/html; charset=<%$HTML{ENCODING}%>">
<style type="text/css">
<!--
body { background : #000040;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MPMinus/REST.pm view on Meta::CPAN
my $meth = uc($r->method() || 'GET');
my $is_get = $meth =~ /GET|HEAD/ ? 1 : 0;
my $headers = $r->headers_in(); # APR::Table object
# If content-type is predefined! Nothing to do
my $content_type = $self->get_attr("content_type");
if ($content_type) {
$self->set_svar(format => _ctlookup($content_type) || FORMAT);
$r->content_type($content_type);
return Apache2::Const::OK;
}
# Content-Type Values from headers
my $req_content_type = $headers->get("content-type") // '';
my $req_accept = $headers->get("accept") // '';
# Try get format from request header first and from the Accept header
my $format = _ctlookup($req_content_type) || _ctlookup($req_accept);
my $default_format = $format || FORMAT;
view all matches for this distribution
view release on metacpan or search on metacpan
Changes.html view on Meta::CPAN
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Changes.src</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:perlcore@ms.com" />
</head>
<body style="background-color: white">
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MT/Import/Mbox.pm view on Meta::CPAN
event that no attachments are found it returns the body of the orginal message
as a 'part', or attachment.
If only one attachment exists it is used to generate the body of the entry.
If the first attachment content-type is determined to be either plain-text
or HTML it is used to generate the body of the entry.
All other attachments are written to disk. Attachments are written to disk as :
/your/static/weblog/attachments/$YYYY/$MM/$DD/$MSG_ID/$FNAME
lib/MT/Import/Mbox.pm view on Meta::CPAN
$MSG_ID is an MD5 digest of a normalized form of the message's Message-ID
header.
$FNAME is an MD5 digest of the attachment's body. If it is possible to
determine the attachment's content-type then a suitable extension is
appended to $FNAME.
A messsage's headers are stored as a separate attachment in :
/your/static/weblog/attachments/$YYYY/$MM/$DD/$MSG_ID/headers.txt
view all matches for this distribution