跳到主要内容

set_content

设置响应内容

如果指定了content_type,data必须为buffer或string;否则,将根据data的类型推断content_type:

  • 若data是buffer,则content_type被推断为"application/octet-stream"

  • 若data是string,则content_type被推断为"text/plain"

  • 否则,将data进行json编码,content_type被推断为"application/json"

声明

void set_content(Response self, mixed data, string content_type = nil)

参数

参数名描述
self
data内容数据
content_type可选的内容类型

返回值

使用方式

返回文档