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

📄 request.html

📁 perl教程
💻 HTML
字号:
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>HTTP::Request - HTTP style request message</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>

<script>writelinks('__top__',2);</script>
<h1><a>HTTP::Request - HTTP style request message</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<li><a href="#see_also">SEE ALSO</a></li>
	<li><a href="#copyright">COPYRIGHT</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>HTTP::Request - HTTP style request message</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
 <span class="keyword">require</span> <span class="variable">HTTP::Request</span><span class="operator">;</span>
 <span class="variable">$request</span> <span class="operator">=</span> <span class="variable">HTTP::Request</span><span class="operator">-&gt;</span><span class="variable">new</span><span class="operator">(</span><span class="string">GET</span> <span class="operator">=&gt;</span> <span class="string">'http://www.example.com/'</span><span class="operator">);</span>
</pre>
<p>and usually used like this:</p>
<pre>
 <span class="variable">$ua</span> <span class="operator">=</span> <span class="variable">LWP::UserAgent</span><span class="operator">-&gt;</span><span class="variable">new</span><span class="operator">;</span>
 <span class="variable">$response</span> <span class="operator">=</span> <span class="variable">$ua</span><span class="operator">-&gt;</span><span class="variable">request</span><span class="operator">(</span><span class="variable">$request</span><span class="operator">);</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p><code>HTTP::Request</code> is a class encapsulating HTTP style requests,
consisting of a request line, some headers, and a content body. Note
that the LWP library uses HTTP style requests even for non-HTTP
protocols.  Instances of this class are usually passed to the
<code>request()</code> method of an <code>LWP::UserAgent</code> object.</p>
<p><code>HTTP::Request</code> is a subclass of <code>HTTP::Message</code> and therefore
inherits its methods.  The following additional methods are available:</p>
<dl>
<dt><strong><a name="item_new">$r = HTTP::Request-&gt;new( $method, $uri )</a></strong>

<dt><strong>$r = HTTP::Request-&gt;new( $method, $uri, $header )</strong>

<dt><strong>$r = HTTP::Request-&gt;new( $method, $uri, $header, $content )</strong>

<dd>
<p>Constructs a new <code>HTTP::Request</code> object describing a request on the
object $uri using method $method.  The $method argument must be a
string.  The $uri argument can be either a string, or a reference to a
<code>URI</code> object.  The optional $header argument should be a reference to
an <code>HTTP::Headers</code> object or a plain array reference of key/value
pairs.  The optional $content argument should be a string of bytes.</p>
</dd>
</li>
<dt><strong><a name="item_parse">$r = HTTP::Request-&gt;parse( $str )</a></strong>

<dd>
<p>This constructs a new request object by parsing the given string.</p>
</dd>
</li>
<dt><strong><a name="item_method">$r-&gt;method</a></strong>

<dt><strong>$r-&gt;method( $val )</strong>

<dd>
<p>This is used to get/set the method attribute.  The method should be a
short string like &quot;GET&quot;, &quot;HEAD&quot;, &quot;PUT&quot; or &quot;POST&quot;.</p>
</dd>
</li>
<dt><strong><a name="item_uri">$r-&gt;uri</a></strong>

<dt><strong>$r-&gt;uri( $val )</strong>

<dd>
<p>This is used to get/set the uri attribute.  The $val can be a
reference to a URI object or a plain string.  If a string is given,
then it should be parseable as an absolute URI.</p>
</dd>
</li>
<dt><strong><a name="item_header">$r-&gt;header( $field )</a></strong>

<dt><strong>$r-&gt;header( $field =&gt; $value )</strong>

<dd>
<p>This is used to get/set header values and it is inherited from
<code>HTTP::Headers</code> via <code>HTTP::Message</code>.  See <a href="../../lib/HTTP/Headers.html">the HTTP::Headers manpage</a> for
details and other similar methods that can be used to access the
headers.</p>
</dd>
</li>
<dt><strong><a name="item_content">$r-&gt;content</a></strong>

<dt><strong>$r-&gt;content( $content )</strong>

<dd>
<p>This is used to get/set the content and it is inherited from the
<code>HTTP::Message</code> base class.  See <a href="../../lib/HTTP/Message.html">the HTTP::Message manpage</a> for details and
other methods that can be used to access the content.</p>
</dd>
<dd>
<p>Note that the content should be a string of bytes.  Strings in perl
can contain characters outside the range of a byte.  The <code>Encode</code>
module can be used to turn such strings into a string of bytes.</p>
</dd>
</li>
<dt><strong><a name="item_as_string">$r-&gt;as_string</a></strong>

<dt><strong>$r-&gt;as_string( $eol )</strong>

<dd>
<p>Method returning a textual representation of the request.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="../../lib/HTTP/Headers.html">the HTTP::Headers manpage</a>, <a href="../../lib/HTTP/Message.html">the HTTP::Message manpage</a>, <a href="../../lib/HTTP/Request/Common.html">the HTTP::Request::Common manpage</a>,
<a href="../../lib/HTTP/Response.html">the HTTP::Response manpage</a></p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright 1995-2004 Gisle Aas.</p>
<p>This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.</p>

</body>

</html>

⌨️ 快捷键说明

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