⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lwp::useragent.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 3 页
字号:
Returns the default agent identifier.  This is a string of the form\&\*(L"libwww\-perl/#.##\*(R", where \*(L"#.##\*(R" is substituted with the version numberof this library..ie n .IP "$ua\->from" 4.el .IP "\f(CW$ua\fR\->from" 4.IX Item "$ua->from".PD 0.ie n .IP "$ua\fR\->from( \f(CW$email_address )" 4.el .IP "\f(CW$ua\fR\->from( \f(CW$email_address\fR )" 4.IX Item "$ua->from( $email_address )".PDGet/set the e\-mail address for the human user who controlsthe requesting user agent.  The address should be machine-usable, asdefined in \s-1RFC\s0 822.  The \f(CW\*(C`from\*(C'\fR value is send as the \*(L"From\*(R" header inthe requests.  Example:.Sp.Vb 1\&  $ua\->from(\*(Aqgaas@cpan.org\*(Aq);.Ve.SpThe default is to not send a \*(L"From\*(R" header.  See the \fIdefault_headers()\fRmethod for the more general interface that allow any header to be defaulted..ie n .IP "$ua\->cookie_jar" 4.el .IP "\f(CW$ua\fR\->cookie_jar" 4.IX Item "$ua->cookie_jar".PD 0.ie n .IP "$ua\fR\->cookie_jar( \f(CW$cookie_jar_obj )" 4.el .IP "\f(CW$ua\fR\->cookie_jar( \f(CW$cookie_jar_obj\fR )" 4.IX Item "$ua->cookie_jar( $cookie_jar_obj )".PDGet/set the cookie jar object to use.  The only requirement is thatthe cookie jar object must implement the extract_cookies($request) andadd_cookie_header($response) methods.  These methods will then beinvoked by the user agent as requests are sent and responses arereceived.  Normally this will be a \f(CW\*(C`HTTP::Cookies\*(C'\fR object or somesubclass..SpThe default is to have no cookie_jar, i.e. never automatically add\&\*(L"Cookie\*(R" headers to the requests..SpShortcut: If a reference to a plain hash is passed in as the\&\f(CW$cookie_jar_object\fR, then it is replaced with an instance of\&\f(CW\*(C`HTTP::Cookies\*(C'\fR that is initialized based on the hash.  This form alsoautomatically loads the \f(CW\*(C`HTTP::Cookies\*(C'\fR module.  It means that:.Sp.Vb 1\&  $ua\->cookie_jar({ file => "$ENV{HOME}/.cookies.txt" });.Ve.Spis really just a shortcut for:.Sp.Vb 2\&  require HTTP::Cookies;\&  $ua\->cookie_jar(HTTP::Cookies\->new(file => "$ENV{HOME}/.cookies.txt"));.Ve.ie n .IP "$ua\->default_headers" 4.el .IP "\f(CW$ua\fR\->default_headers" 4.IX Item "$ua->default_headers".PD 0.ie n .IP "$ua\fR\->default_headers( \f(CW$headers_obj )" 4.el .IP "\f(CW$ua\fR\->default_headers( \f(CW$headers_obj\fR )" 4.IX Item "$ua->default_headers( $headers_obj )".PDGet/set the headers object that will provide default header values forany requests sent.  By default this will be an empty \f(CW\*(C`HTTP::Headers\*(C'\fRobject.  Example:.Sp.Vb 1\&  $ua\->default_headers\->push_header(\*(AqAccept\-Language\*(Aq => "no, en");.Ve.ie n .IP "$ua\fR\->default_header( \f(CW$field )" 4.el .IP "\f(CW$ua\fR\->default_header( \f(CW$field\fR )" 4.IX Item "$ua->default_header( $field )".PD 0.ie n .IP "$ua\fR\->default_header( \f(CW$field\fR => \f(CW$value )" 4.el .IP "\f(CW$ua\fR\->default_header( \f(CW$field\fR => \f(CW$value\fR )" 4.IX Item "$ua->default_header( $field => $value )".PDThis is just a short-cut for \f(CW$ua\fR\->default_headers\->header( \f(CW$field\fR =>\&\f(CW$value\fR ). Example:.Sp.Vb 1\&  $ua\->default_header(\*(AqAccept\-Language\*(Aq => "no, en");.Ve.ie n .IP "$ua\->conn_cache" 4.el .IP "\f(CW$ua\fR\->conn_cache" 4.IX Item "$ua->conn_cache".PD 0.ie n .IP "$ua\fR\->conn_cache( \f(CW$cache_obj )" 4.el .IP "\f(CW$ua\fR\->conn_cache( \f(CW$cache_obj\fR )" 4.IX Item "$ua->conn_cache( $cache_obj )".PDGet/set the \f(CW\*(C`LWP::ConnCache\*(C'\fR object to use.  See LWP::ConnCachefor details..ie n .IP "$ua\fR\->credentials( \f(CW$netloc\fR, \f(CW$realm\fR, \f(CW$uname\fR, \f(CW$pass )" 4.el .IP "\f(CW$ua\fR\->credentials( \f(CW$netloc\fR, \f(CW$realm\fR, \f(CW$uname\fR, \f(CW$pass\fR )" 4.IX Item "$ua->credentials( $netloc, $realm, $uname, $pass )"Set the user name and password to be used for a realm.  It is often moreuseful to specialize the \fIget_basic_credentials()\fR method instead..ie n .IP "$ua\->max_size" 4.el .IP "\f(CW$ua\fR\->max_size" 4.IX Item "$ua->max_size".PD 0.ie n .IP "$ua\fR\->max_size( \f(CW$bytes )" 4.el .IP "\f(CW$ua\fR\->max_size( \f(CW$bytes\fR )" 4.IX Item "$ua->max_size( $bytes )".PDGet/set the size limit for response content.  The default is \f(CW\*(C`undef\*(C'\fR,which means that there is no limit.  If the returned response contentis only partial, because the size limit was exceeded, then a\&\*(L"Client-Aborted\*(R" header will be added to the response.  The contentmight end up longer than \f(CW\*(C`max_size\*(C'\fR as we abort once appending achunk of data makes the length exceed the limit.  The \*(L"Content-Length\*(R"header, if present, will indicate the length of the full content andwill normally not be the same as \f(CW\*(C`length($res\->content)\*(C'\fR..ie n .IP "$ua\->max_redirect" 4.el .IP "\f(CW$ua\fR\->max_redirect" 4.IX Item "$ua->max_redirect".PD 0.ie n .IP "$ua\fR\->max_redirect( \f(CW$n )" 4.el .IP "\f(CW$ua\fR\->max_redirect( \f(CW$n\fR )" 4.IX Item "$ua->max_redirect( $n )".PDThis reads or sets the object's limit of how many times it will obeyredirection responses in a given request cycle..SpBy default, the value is 7. This means that if you call \fIrequest()\fRmethod and the response is a redirect elsewhere which is in turn aredirect, and so on seven times, then \s-1LWP\s0 gives up after that seventhrequest..ie n .IP "$ua\->parse_head" 4.el .IP "\f(CW$ua\fR\->parse_head" 4.IX Item "$ua->parse_head".PD 0.ie n .IP "$ua\fR\->parse_head( \f(CW$boolean )" 4.el .IP "\f(CW$ua\fR\->parse_head( \f(CW$boolean\fR )" 4.IX Item "$ua->parse_head( $boolean )".PDGet/set a value indicating whether we should initialize responseheaders from the <head> section of \s-1HTML\s0 documents. The default is\&\s-1TRUE\s0.  Do not turn this off, unless you know what you are doing..ie n .IP "$ua\->protocols_allowed" 4.el .IP "\f(CW$ua\fR\->protocols_allowed" 4.IX Item "$ua->protocols_allowed".PD 0.ie n .IP "$ua\->protocols_allowed( \e@protocols )" 4.el .IP "\f(CW$ua\fR\->protocols_allowed( \e@protocols )" 4.IX Item "$ua->protocols_allowed( @protocols )".PDThis reads (or sets) this user agent's list of protocols that therequest methods will exclusively allow.  The protocol names are caseinsensitive..SpFor example: \f(CW\*(C`$ua\->protocols_allowed( [ \*(Aqhttp\*(Aq, \*(Aqhttps\*(Aq] );\*(C'\fRmeans that this user agent will \fIallow only\fR those protocols,and attempts to use this user agent to access URLs with any otherschemes (like \*(L"ftp://...\*(R") will result in a 500 error..SpTo delete the list, call: \f(CW\*(C`$ua\->protocols_allowed(undef)\*(C'\fR.SpBy default, an object has neither a \f(CW\*(C`protocols_allowed\*(C'\fR list, nor a\&\f(CW\*(C`protocols_forbidden\*(C'\fR list..SpNote that having a \f(CW\*(C`protocols_allowed\*(C'\fR list causes any\&\f(CW\*(C`protocols_forbidden\*(C'\fR list to be ignored..ie n .IP "$ua\->protocols_forbidden" 4.el .IP "\f(CW$ua\fR\->protocols_forbidden" 4.IX Item "$ua->protocols_forbidden".PD 0.ie n .IP "$ua\->protocols_forbidden( \e@protocols )" 4.el .IP "\f(CW$ua\fR\->protocols_forbidden( \e@protocols )" 4.IX Item "$ua->protocols_forbidden( @protocols )".PDThis reads (or sets) this user agent's list of protocols that therequest method will \fInot\fR allow. The protocol names are caseinsensitive..SpFor example: \f(CW\*(C`$ua\->protocols_forbidden( [ \*(Aqfile\*(Aq, \*(Aqmailto\*(Aq] );\*(C'\fRmeans that this user agent will \fInot\fR allow those protocols, andattempts to use this user agent to access URLs with those schemeswill result in a 500 error..SpTo delete the list, call: \f(CW\*(C`$ua\->protocols_forbidden(undef)\*(C'\fR.ie n .IP "$ua\->requests_redirectable" 4.el .IP "\f(CW$ua\fR\->requests_redirectable" 4.IX Item "$ua->requests_redirectable".PD 0.ie n .IP "$ua\->requests_redirectable( \e@requests )" 4.el .IP "\f(CW$ua\fR\->requests_redirectable( \e@requests )" 4.IX Item "$ua->requests_redirectable( @requests )".PDThis reads or sets the object's list of request names that\&\f(CW\*(C`$ua\->redirect_ok(...)\*(C'\fR will allow redirection for.  Bydefault, this is \f(CW\*(C`[\*(AqGET\*(Aq, \*(AqHEAD\*(Aq]\*(C'\fR, as per \s-1RFC\s0 2616.  Tochange to include '\s-1POST\s0', consider:.Sp.Vb 1\&   push @{ $ua\->requests_redirectable }, \*(AqPOST\*(Aq;.Ve.ie n .IP "$ua\->timeout" 4.el .IP "\f(CW$ua\fR\->timeout" 4.IX Item "$ua->timeout".PD 0.ie n .IP "$ua\fR\->timeout( \f(CW$secs )" 4.el .IP "\f(CW$ua\fR\->timeout( \f(CW$secs\fR )" 4.IX Item "$ua->timeout( $secs )".PDGet/set the timeout value in seconds. The default \fItimeout()\fR value is180 seconds, i.e. 3 minutes..SpThe requests is aborted if no activity on the connection to the serveris observed for \f(CW\*(C`timeout\*(C'\fR seconds.  This means that the time it takesfor the complete transaction and the \fIrequest()\fR method to actuallyreturn might be longer..Sh "Proxy attributes".IX Subsection "Proxy attributes"The following methods set up when requests should be passed via aproxy server..ie n .IP "$ua\fR\->proxy(\e@schemes, \f(CW$proxy_url)" 4.el .IP "\f(CW$ua\fR\->proxy(\e@schemes, \f(CW$proxy_url\fR)" 4.IX Item "$ua->proxy(@schemes, $proxy_url)".PD 0.ie n .IP "$ua\fR\->proxy($scheme, \f(CW$proxy_url)" 4.el .IP "\f(CW$ua\fR\->proxy($scheme, \f(CW$proxy_url\fR)" 4.IX Item "$ua->proxy($scheme, $proxy_url)".PDSet/retrieve proxy \s-1URL\s0 for a scheme:.Sp.Vb 2\& $ua\->proxy([\*(Aqhttp\*(Aq, \*(Aqftp\*(Aq], \*(Aqhttp://proxy.sn.no:8001/\*(Aq);\& $ua\->proxy(\*(Aqgopher\*(Aq, \*(Aqhttp://proxy.sn.no:8001/\*(Aq);.Ve.SpThe first form specifies that the \s-1URL\s0 is to be used for proxying ofaccess methods listed in the list in the first method argument,i.e. 'http' and 'ftp'..SpThe second form shows a shorthand form for specifyingproxy \s-1URL\s0 for a single access scheme..ie n .IP "$ua\fR\->no_proxy( \f(CW$domain, ... )" 4.el .IP "\f(CW$ua\fR\->no_proxy( \f(CW$domain\fR, ... )" 4.IX Item "$ua->no_proxy( $domain, ... )"Do not proxy requests to the given domains.  Calling no_proxy withoutany domains clears the list of domains. Eg:.Sp.Vb 1\& $ua\->no_proxy(\*(Aqlocalhost\*(Aq, \*(Aqno\*(Aq, ...);.Ve.ie n .IP "$ua\->env_proxy" 4.el .IP "\f(CW$ua\fR\->env_proxy" 4.IX Item "$ua->env_proxy"Load proxy settings from *_proxy environment variables.  You mightspecify proxies like this (sh-syntax):.Sp.Vb 4\&  gopher_proxy=http://proxy.my.place/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -