OpenSwoole\HTTP\Request->create()

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

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

Parameters

options

An array of HTTP request options to set

Return

OpenSwoole\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 OpenSwoole\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
OpenSwoole\HTTP\Request->create([
    'parse_cookie' => true,
]);

Sets whether to resolve any HTTP cookies.

parse_body

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

Sets whether to resolve the HTTP POST body.

parse_files

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

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

enable_compression

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

Sets whether to enable compression or not.

compression_level

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

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

Last updated on September 1, 2022