Swoole\HTTP\Request->create()

Declaration

<?php
Swoole\HTTP\Request->create(string $options): Swoole\Http\Request|false

Parameters

options

An array of HTTP request options to set

Return

Swoole\Http\Request or false

Description

Create a new HTTP request object from scratch, this give you much more flexibility when passing the HTTP request object either to a downstream service or framework.

You are recreating the request object from Swoole\Http\Request that was given to you from the server, not an actual new request.

Since version 4.6.0+

HTTP Request Creation Array Options

<?php
Swoole\HTTP\Request->create([
    'parse_cookie' => true,
]);

Sets whether to resolve any HTTP cookies.

parse_body

<?php
Swoole\HTTP\Request->create([
    'parse_body' => true,
]);

Sets whether to resolve the HTTP POST body.

parse_files

<?php
Swoole\HTTP\Request->create([
    'parse_files' => true,
]);

Sets whether to resolve any HTTP files that were sent to the server.

enable_compression

<?php
Swoole\HTTP\Request->create([
    'enable_compression' => true,
]);

Sets whether to enable compression or not.

compression_level

<?php
Swoole\HTTP\Request->create([
    'compression_level' => 1,
]);

Sets the compression level, from 1-9, the higher the smaller the request size but more CPU usage.