HTTP Request

HTTPRequest - HTTP style request message  HTTP请求消息的方式:

介绍:

 require HTTP::Request;
 $request = HTTP::Request->new(GET => 'http://www.example.com/');

类似于:

 $ua = LWP::UserAgent->new;
 $response = $ua->request($request);

描述:

HTTP::Request 是一个 类封装了HTTP类型的请求, 有一个请求行,一些header 和一些content body.


注意 LWP 库使用HTTP 类型请求甚至用于非HTTP协议。




这个类的实例是通常传递给LWP::UserAgent object.的request() 方法



HTTP::Request 是一个 HTTP::Message 的子类,因此继承了它的方法,下面的额外的方法是可用的:

$r = HTTP::Request->new( $method, $uri )
$r = HTTP::Request->new( $method, $uri, $header )
$r = HTTP::Request->new( $method, $uri, $header, $content )


构建一个新的HTTP::Request 对象描述一个请求在对象$uri 使用方法$method.


$method 参数必须是一个字符串, $uri 参数可以是一个字符串,或者一个URI对象的引用。


可选的$header 参数应该是一个引用到HTTP::Headers object 或者一个纯数组引用 键值对。


可选的$content的参数应该是一个字节串












原文地址:https://www.cnblogs.com/hzcya1995/p/13351138.html