Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change header Content-Type: text/html;charset=utf-8 to application/json #2

Open
haidarvm opened this issue Aug 11, 2020 · 4 comments

Comments

@haidarvm
Copy link

For better handling in some programming we detect Header Content-type json,
I did add header('Content-Type: application/json');
but still don't work

@passwalls
Copy link
Owner

For example.
use Workerman/Protocols/Http/Response;
// .....
return new Response(200, [“ Content-Type” => “ application/json”], json_encode($data));

@haidarvm
Copy link
Author

Ok, Great its work

use Workerman\Protocols\Http\Response;
new Response(200, ["Content-Type" => "application/json"], json_encode($data));

but it's make performance little bit slower when I'm using wrk

@joanhey
Copy link

joanhey commented Apr 26, 2023

The performance is the same, but you have to json_encode() the data.

@abdullahhosenakash
Copy link

in my case, i parsed the data by using await response.text() rather than await response.json()
await response.text() works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants