openswoole / ext-openswoole

Programmatic server for PHP with async IO, coroutines and fibers
https://openswoole.com
Apache License 2.0
801 stars 50 forks source link

$_SERVER analog not full #354

Open Tuezov52 opened 8 months ago

Tuezov52 commented 8 months ago

I need to get the request data schema(http or https) and host(site.ru or www.site.ru ). php has $_SERVER['REQUEST_SCHEME'] and $_SERVER['HTTP_HOST']. I've tried, how do I get them? PS "At the moment, I only see $request->server['request_uri'] and $request->server['query_string']"

bitslip6 commented 4 months ago

The variables you are looking for are in $request->header and are NOT prefixed with 'HTTP_' so:

$request->header['host'] = $_SERVER['HTTP_HOST'], etc..