Skip to content

Commit

Permalink
added content and content_type attrs for Attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnavy committed May 27, 2009
1 parent 1891837 commit 4c6998c
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions lib/Net/Trac/TicketAttachment.pm
Expand Up @@ -57,6 +57,19 @@ has description => ( isa => 'Str', is => 'rw' );
has url => ( isa => 'Str', is => 'rw' );
has author => ( isa => 'Str', is => 'rw' );
has size => ( isa => 'Int', is => 'rw' );
has content => (
isa => 'Str',
is => 'rw',
lazy => 1,
default => sub { $_[0]->_load },
);

has content_type => (
isa => 'Str',
is => 'rw',
lazy => 1,
default => sub { $_[0]->_load },
);


=head1 PRIVATE METHODS
Expand Down Expand Up @@ -120,9 +133,16 @@ sub _parse_html_chunk {
return 1;
}

sub content {
sub _load {
my $self = shift;
return $self->connection->_fetch( $self->url );
my $content = $self->connection->_fetch( $self->url );
my $content_type;
my $type_header = $self->connection->mech->response->header('Content-Type');
if ( $type_header =~ /(\S+?);/ ) {
$content_type = $1;
}
$self->content( $content );
$self->content_type( $content_type );
}

=head1 LICENSE
Expand Down

0 comments on commit 4c6998c

Please sign in to comment.