request.setHeader(name, value)
为标头对象设置单个标头值。
如果该标头已经存在于待发送的标头中,则其值将被替换。
在此处使用字符串数组发送具有相同名称的多个标头。
非字符串值将不加修改地存储。
因此,request.getHeader() 可能返回非字符串值。
但是,非字符串值将转换为字符串以进行网络传输。
request.setHeader('Content-Type', 'application/json');或者
request.setHeader('Cookie', ['type=ninja', 'language=javascript']);Sets a single header value for headers object. If this header already exists in
the to-be-sent headers, its value will be replaced. Use an array of strings
here to send multiple headers with the same name. Non-string values will be
stored without modification. Therefore, request.getHeader() may return
non-string values. However, the non-string values will be converted to strings
for network transmission.
request.setHeader('Content-Type', 'application/json');or
request.setHeader('Cookie', ['type=ninja', 'language=javascript']);