当内容类型没有在http中发送时会出现什么问题?

时间:2016-09-08 17:17:55

标签: http

在httpresponse标头中未发送内容类型时会出现什么问题?具体来说,如果省略了content_type,JSON类型会发生什么?如下所示?

class JSONResponse(HttpResponse):
"""
An HttpResponse that renders its content into JSON.
"""
def __init__(self, data, **kwargs):
    content = JSONRenderer().render(data)
    kwargs['content_type'] = 'application/json'
    super(JSONResponse, self).__init__(content, **kwargs)

1 个答案:

答案 0 :(得分:0)

根据HTTP规范内容类型应该作为其中一个标题传递,没有"默认值"。如果客户端没有实现它 - 它可以由服务器的实现来决定在响应中返回什么。请参阅7.2.1

的最后一节