亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? protocol.pm

?? ARM上的如果你對底層感興趣
?? PM
字號:
# $Id: Protocol.pm,v 1.31 1998/01/06 09:58:38 aas Exp $

package LWP::Protocol;

=head1 NAME

LWP::Protocol - Base class for LWP protocols

=head1 SYNOPSIS

 package LWP::Protocol::foo;
 require LWP::Protocol;
 @ISA=qw(LWP::Protocol);

=head1 DESCRIPTION

This class is used a the base class for all protocol implementations
supported by the LWP library.

When creating an instance of this class using
C<LWP::Protocol::create($url)>, and you get an initialised subclass
appropriate for that access method. In other words, the
LWP::Protocol::create() function calls the constructor for one of its
subclasses.

All derived LWP::Protocol classes need to override the request()
method which is used to service a request. The overridden method can
make use of the collect() function to collect together chunks of data
as it is received.

The following methods and functions are provided:

=over 4

=cut

#####################################################################

require LWP::MemberMixin;
@ISA = qw(LWP::MemberMixin);
$VERSION = sprintf("%d.%02d", q$Revision: 1.31 $ =~ /(\d+)\.(\d+)/);

use strict;
use Carp ();
use HTTP::Status 'RC_INTERNAL_SERVER_ERROR';
require HTML::HeadParser;

my %ImplementedBy = (); # scheme => classname


=item $prot = new HTTP::Protocol;

The LWP::Protocol constructor is inherited by subclasses. As this is a
virtual base class this method should B<not> be called directly.

=cut

sub new
{
    my($class) = @_;

    my $self = bless {
	'timeout' => 0,
	'parse_head' => 1,
    }, $class;
    $self;
}


=item $prot = LWP::Protocol::create($url)

Create an object of the class implementing the protocol to handle the
given scheme. This is a function, not a method. It is more an object
factory than a constructor. This is the function user agents should
use to access protocols.

=cut

sub create
{
    my $scheme = shift;
    my $impclass = LWP::Protocol::implementor($scheme) or
	Carp::croak("Protocol scheme '$scheme' is not supported");

    # hand-off to scheme specific implementation sub-class
    return $impclass->new($scheme);
}


=item $class = LWP::Protocol::implementor($scheme, [$class])

Get and/or set implementor class for a scheme.  Returns '' if the
specified scheme is not supported.

=cut

sub implementor
{
    my($scheme, $impclass) = @_;

    if ($impclass) {
	$ImplementedBy{$scheme} = $impclass;
    }
    my $ic = $ImplementedBy{$scheme};
    return $ic if $ic;

    return '' unless $scheme =~ /^([.+\-\w]+)$/;  # check valid URL schemes
    $scheme = $1; # untaint
    $scheme =~ s/[.+\-]/_/g;  # make it a legal module name

    # scheme not yet known, look for a 'use'd implementation
    $ic = "LWP::Protocol::$scheme";  # default location
    $ic = "LWP::Protocol::nntp" if $scheme eq 'news'; #XXX ugly hack
    no strict 'refs';
    # check we actually have one for the scheme:
    unless (defined @{"${ic}::ISA"}) {
	# try to autoload it
	eval "require $ic";
	if ($@) {
	    if ($@ =~ /^Can't locate/) { #' #emacs get confused by '
		$ic = '';
	    } else {
		die "$@\n";
	    }
	}
    }
    $ImplementedBy{$scheme} = $ic if $ic;
    $ic;
}


=item $prot->request(...)

 $response = $protocol->request($request, $proxy, undef);
 $response = $protocol->request($request, $proxy, '/tmp/sss');
 $response = $protocol->request($request, $proxy, \&callback, 1024);

Dispactches a request over the protocol, and returns a response
object. This method needs to be overridden in subclasses.  Referer to
L<LWP::UserAgent> for description of the arguments.

=cut

sub request
{
    my($self, $request, $proxy, $arg, $size, $timeout) = @_;
    Carp::croak('LWP::Protocol::request() needs to be overridden in subclasses');
}


=item $prot->timeout($seconds)

Get and set the timeout value in seconds


=item $prot->parse_head($yesno)

Should we initialize response headers from the <head> section of HTML
documents.

=cut

sub timeout    { shift->_elem('timeout',    @_); }
sub parse_head { shift->_elem('parse_head', @_); }
sub max_size   { shift->_elem('max_size',   @_); }


=item $prot->collect($arg, $response, $collector)

Called to collect the content of a request, and process it
appropriately into a scalar, file, or by calling a callback.  If $arg
is undefined, then the content is stored within the $response.  If
$arg is a simple scalar, then $arg is interpreted as a file name and
the content is written to this file.  If $arg is a reference to a
routine, then content is passed to this routine.

The $collector is a routine that will be called and which is
reponsible for returning pieces (as ref to scalar) of the content to
process.  The $collector signals EOF by returning a reference to an
empty sting.

The return value from collect() is the $response object reference.

B<Note:> We will only use the callback or file argument if
$response->is_success().  This avoids sendig content data for
redirects and authentization responses to the callback which would be
confusing.

=cut

sub collect
{
    my ($self, $arg, $response, $collector) = @_;
    my $content;
    my($parse_head, $timeout, $max_size) =
      @{$self}{qw(parse_head timeout max_size)};

    my $parser;
    if ($parse_head && $response->content_type eq 'text/html') {
	$parser = HTML::HeadParser->new($response->{'_headers'});
    }
    my $content_size = 0;

    if (!defined($arg) || !$response->is_success) {
	# scalar
	while ($content = &$collector, length $$content) {
	    if ($parser) {
		$parser->parse($$content) or undef($parser);
	    }
	    LWP::Debug::debug("read " . length($$content) . " bytes");
	    $response->add_content($$content);
	    $content_size += length($$content);
	    if ($max_size && $content_size > $max_size) {
		LWP::Debug::debug("Aborting because size limit exceeded");
		my $tot = $response->header("Content-Length") || 0;
		$response->header("X-Content-Range", "bytes 0-$content_size/$tot");
		last;
	    }
	}
    }
    elsif (!ref($arg)) {
	# filename
	open(OUT, ">$arg") or
	    return new HTTP::Response RC_INTERNAL_SERVER_ERROR,
			  "Cannot write to '$arg': $!";
        binmode(OUT);
        local($\) = ""; # ensure standard $OUTPUT_RECORD_SEPARATOR
	while ($content = &$collector, length $$content) {
	    if ($parser) {
		$parser->parse($$content) or undef($parser);
	    }
	    LWP::Debug::debug("read " . length($$content) . " bytes");
	    print OUT $$content;
	    $content_size += length($$content);
	    if ($max_size && $content_size > $max_size) {
		LWP::Debug::debug("Aborting because size limit exceeded");
		my $tot = $response->header("Content-Length") || 0;
		$response->header("X-Content-Range", "bytes 0-$content_size/$tot");
		last;
	    }
	}
	close(OUT);
    }
    elsif (ref($arg) eq 'CODE') {
	# read into callback
	while ($content = &$collector, length $$content) {
	    if ($parser) {
		$parser->parse($$content) or undef($parser);
	    }
	    LWP::Debug::debug("read " . length($$content) . " bytes");
            eval {
		&$arg($$content, $response, $self);
	    };
	    if ($@) {
	        chomp($@);
		$response->header('X-Died' => $@);
		last;
	    }
	}
    }
    else {
	return new HTTP::Response RC_INTERNAL_SERVER_ERROR,
				  "Unexpected collect argument  '$arg'";
    }
    $response;
}


=item $prot->collect_once($arg, $response, $content)

Can be called when the whole response content is available as
$content.  This will invoke collect() with a collector callback that
returns a reference to $content the first time and an empty string the
next.

=cut

sub collect_once
{
    my($self, $arg, $response) = @_;
    my $content = \ $_[3];
    my $first = 1;
    $self->collect($arg, $response, sub {
	return $content if $first--;
	return \ "";
    });
}

1;

=head1 SEE ALSO

Inspect the F<LWP/Protocol/file.pm> and F<LWP/Protocol/http.pm> files
for examples of usage.

=head1 COPYRIGHT

Copyright 1995-1997 Gisle Aas.

This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

=cut

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产69精品一区二区亚洲孕妇 | 日本亚洲视频在线| 在线播放91灌醉迷j高跟美女 | 韩国理伦片一区二区三区在线播放| 久久久久久久电影| 欧美精品第一页| 一本一本大道香蕉久在线精品| 国产精品夜夜爽| 精品一区精品二区高清| 一区二区三区中文字幕| 国产午夜精品久久久久久免费视| 日韩一区二区三免费高清| 91性感美女视频| 成人激情午夜影院| 日韩专区在线视频| 午夜在线成人av| 亚洲六月丁香色婷婷综合久久| 精品福利av导航| 色婷婷国产精品久久包臀| 成人精品免费视频| 日韩视频一区二区三区在线播放| 精品电影一区二区三区 | 欧美韩日一区二区三区四区| 亚洲欧洲另类国产综合| 欧美激情一区二区三区在线| 在线电影国产精品| 精品欧美黑人一区二区三区| 精品99久久久久久| 亚洲精品视频自拍| 人人精品人人爱| 欧美日韩一级片在线观看| 国产精品每日更新在线播放网址| 亚洲主播在线观看| 不卡欧美aaaaa| 欧美日韩国产片| 一区二区三区在线观看动漫| 亚洲欧美国产三级| 亚洲高清免费视频| 99r精品视频| 久久久久久一级片| 成人免费视频播放| 国产午夜亚洲精品理论片色戒 | 成人免费福利片| 高清不卡一区二区在线| 欧美日韩卡一卡二| 亚洲一二三区不卡| 8v天堂国产在线一区二区| 亚洲男人天堂av| 色综合一个色综合亚洲| 亚洲在线视频一区| 欧美午夜精品一区二区三区| 亚洲国产中文字幕| 国产欧美一区二区精品仙草咪| 在线成人av网站| 亚洲第一成人在线| 久久久久97国产精华液好用吗| 午夜国产精品影院在线观看| 91年精品国产| 久久精品国产网站| 亚洲精品日日夜夜| 精品国产免费人成电影在线观看四季| 国产美女精品人人做人人爽| av午夜精品一区二区三区| 亚洲欧美电影院| 久久综合狠狠综合久久激情 | 风间由美中文字幕在线看视频国产欧美| 精品1区2区在线观看| 91美女在线视频| 成人性生交大片免费看在线播放| 依依成人精品视频| 91同城在线观看| 日本一区二区三区dvd视频在线| www.亚洲在线| 另类小说图片综合网| 亚洲一区二区成人在线观看| 国产精品久久久久精k8| 国产欧美日韩另类视频免费观看| 91麻豆精品国产91久久久更新时间 | 国产精品看片你懂得| 精品国产一区二区精华| 欧美性一区二区| 欧美视频一区二| 成人毛片在线观看| 成人福利视频网站| 色综合久久久久久久久久久| 91网址在线看| 国内精品在线播放| 视频一区二区国产| 裸体一区二区三区| 日韩一区在线看| 国产日韩欧美在线一区| 亚洲欧美视频在线观看视频| 亚洲二区在线视频| 尤物视频一区二区| 亚洲国产成人porn| 国产精品一区在线观看乱码| 国产精品久久网站| 日韩精品一区在线| 国产精品国产成人国产三级 | 免费在线观看视频一区| 亚洲天堂2016| 国产精品123| 男男成人高潮片免费网站| 亚洲影院在线观看| 成a人片亚洲日本久久| 精品一区二区免费| 日韩一级精品视频在线观看| 国产毛片精品一区| 国产成人免费视| 国产夫妻精品视频| 国产精品久久久久aaaa樱花| av电影在线观看一区| 1024成人网色www| 欧美日韩精品一二三区| 国产日韩av一区| 99热这里都是精品| 成人欧美一区二区三区黑人麻豆| 国产精品亚洲成人| 另类成人小视频在线| 亚洲成人777| 国产精品小仙女| 美女视频网站久久| 免费观看成人av| 亚洲成人精品一区| 亚洲一区二区三区四区的| 国产精品美女久久久久久| 26uuu亚洲综合色欧美| 欧美成人猛片aaaaaaa| 欧美一区二区在线播放| 3751色影院一区二区三区| 8x8x8国产精品| 精品福利一二区| 精品国内片67194| 日韩亚洲电影在线| 欧美成人乱码一区二区三区| 欧美二区在线观看| 欧美一级专区免费大片| 日韩精品一区二区在线观看| 狠狠色伊人亚洲综合成人| 亚洲欧洲国产日韩| 国产亚洲精品中文字幕| 精品国产91乱码一区二区三区| 色婷婷激情一区二区三区| 盗摄精品av一区二区三区| 久久精品99国产国产精| 免费观看在线综合| 日本视频一区二区三区| 日韩中文字幕av电影| 欧美a级一区二区| 色哟哟亚洲精品| 国产人成一区二区三区影院| 日韩电影在线观看网站| 欧美在线观看一区| 亚洲精品中文在线| 成人亚洲一区二区一| 国产精品亚洲人在线观看| 国产一区不卡视频| 91首页免费视频| 欧美日韩视频不卡| 精品国产精品一区二区夜夜嗨| 欧美韩日一区二区三区| 亚洲精品videosex极品| 蜜桃视频第一区免费观看| 高清在线不卡av| 在线亚洲高清视频| 7777精品伊人久久久大香线蕉的| 精品国产成人系列| 伊人一区二区三区| 国产成人aaa| 日韩写真欧美这视频| 亚洲欧美日韩精品久久久久| 亚洲成av人综合在线观看| 国产成a人亚洲精品| 在线视频你懂得一区二区三区| 26uuu久久综合| 免费在线观看一区| 国产成人高清视频| 日本一区二区电影| 97精品国产97久久久久久久久久久久| 国产拍揄自揄精品视频麻豆| 成人午夜电影网站| 国产欧美久久久精品影院| 国产精品综合视频| 亚洲视频资源在线| 欧美日韩中文一区| 麻豆国产精品777777在线| 日韩亚洲欧美中文三级| 国产一区二区精品久久91| 日本一区二区三区高清不卡| 一区二区三区中文字幕电影| 在线日韩国产精品| 久久精品国产免费看久久精品| 欧美成人精品3d动漫h| 国产精品一级二级三级| 亚洲大片免费看| 中文字幕在线播放不卡一区| 欧美唯美清纯偷拍| 97久久超碰国产精品| 久久se这里有精品| 尤物av一区二区|