【发布时间】:2017-01-18 13:08:02
【问题描述】:
我不确定这是否是一个错误或 http 响应包应该如何工作。
在本例中,Content-Type 响应标头不会被设置
// Return the response
w.WriteHeader(http.StatusCreated)
w.Header().Set("Content-Type", "application/json")
w.Write(js)
如果我颠倒标题设置的顺序,它会起作用:
// Return the response
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusCreated)
w.Write(js)
现在这会将标题设置为application/json。这种行为是有意的吗?
【问题讨论】:
标签: go