# string.http 库模块帮助文档

## string 成员列表 <a id="string" href="#string">&#x23;</a>

### string.http(header,body) <a id="string.http" href="#string.http">&#x23;</a>
header 可以是指定请求头名值对的表，  
也可以是任何 web.joinHeaders 兼容的表或数组。  
body 可以是任何数据。  
如果 body 是一个表则转换为 JSON ，  
如果未指定请求头  Content-Type，  
则同时修改其值为 "application/json; charset=utf-8"  

可选在第一个参数前面添加一个字符串参数以加在 HTTP 请求头之前。  
如果有更多参数，则不转换 JSON 且全部转为字符串拼接。  
拼接分隔符为 '\r  
'，header 与 body 间则为 '\r  
\r  
'

## string.http 成员列表 <a id="string.http" href="#string.http">&#x23;</a>

用于构建类 HTTP 请求消息，并解析类 HTTP 应答消息。  
目前应用于 web.edgeTextToSpeech 库。

构建类 HTTP 请求消息

### string.http.parse() <a id="string.http.parse" href="#string.http.parse">&#x23;</a>
按 HTTP 协议兼容规则解析响应消息。  
参数支持字符串或 buffer。  
HTTP 头解析为表对象，头名字转为小写。  
body 作为第二个返回值。  
如果 header 与 body 间只用了单个 '\r  
' 分隔。  
则最后一行转换为 body 返回
