File: nntp.pm

package info (click to toggle)
libwww-perl 5.36-1.1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 848 kB
  • ctags: 400
  • sloc: perl: 6,366; makefile: 51; sh: 6
file content (44 lines) | stat: -rw-r--r-- 1,182 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package URI::URL::nntp;
require URI::URL::_generic;
@ISA = qw(URI::URL::_generic);

use URI::Escape;

sub default_port { 119 }

sub _parse {
    my($self, $init) = @_;
    $self->URI::URL::_generic::_parse($init, qw(netloc path frag));

    my @parts = $self->path_components;
    shift @parts if @parts && $parts[0] eq '';

    $self->{'group'} = uri_unescape($parts[0]);
    $self->{'digits'}= uri_unescape($parts[1]);
}

sub group   { shift->_elem('group',  @_); }
sub digits  { shift->_elem('digits', @_); }
sub article { shift->_elem('digits', @_); }

sub as_string {
    my $self = shift;
    my $str = "$self->{'scheme'}:";
    $str .= "//$self->{'netloc'}" if defined $self->{'netloc'};
    $str .= "/" . uri_escape($self->{'group'}) . "/" .
		  uri_escape($self->{'digits'});
    $str;
}

# Standard methods are not legal for nntp URLs
*path      = \&URI::URL::bad_method;
*epath     = \&URI::URL::bad_method;
*query     = \&URI::URL::bad_method;
*equery    = \&URI::URL::bad_method;
*params    = \&URI::URL::bad_method;
*eparams   = \&URI::URL::bad_method;
*frag      = \&URI::URL::bad_method;
*user      = \&URI::URL::bad_method;
*password  = \&URI::URL::bad_method;

1;