向服务器发送请求,底层会自动建立一个Http2
的stream
。可以同时发起多个请求。
function Coroutine\Http2\Client->send(swoole_http2_request $request) : int | false
swoole_http2_request
类的对象作为参数1
开始自增的奇数false
swoole_http2_request
对象没有任何方法,通过设置对象属性来写入请求相关的信息。
headers
数组,HTTP
头method
字符串,设置请求方法,如GET
、POST
path
字符串,设置URL
路径,如/index.php?a=1&b=2
,必须以/
作为开始cookies
数组,设置COOKIES
data
设置请求的body
,如果为字符串时将直接作为RAW form-data
进行发送data
为数组时,底层自动会打包为x-www-form-urlencoded
格式的POST
内容,并设置Content-Type
为application/x-www-form-urlencoded
pipeline
布尔型,如果设置为true
,发送完$request
后,不关闭stream
,可以继续写入数据内容默认send
方法在发送请求之后,会结束当前的Http2 Stream
,启用PIPELINE
后,底层会保持stream
流,可以多次调用write
方法,向服务器发送数据帧,请参考write
方法。