Skip to content

How to send() rawbody or binary or custom response #105

@ewwink

Description

@ewwink

I want to send custom response using

Workerman\Protocols\Http\Response

$response = new Response(200, [
    'Content-Type'     => 'application/json',
    'Content-Encoding' => 'zstd'
], $compressedData); 

$connection->send($response);

but I get error

TypeError: Adapterman\Http::encode(): Argument #1 ($content) must be of type string, Workerman\Protocols\Http\Response given, 
called in /root/www/vendor/workerman/workerman/src/Connection/TcpConnection.php on line 463 and defined in /root/www/vendor/joanhey/adapterman/src/Http.php:469

If I write $connection->send($compressedData);, the browser can't handle it and displays strange characters because the browser considers it as plain text. How do I set the correct header?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions