如何设置具有不同内容类型的http标头 [英] How to set http headers with different content type

查看:222
本文介绍了如何设置具有不同内容类型的http标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过Python动态创建的网页。它的目的是提供图像,所以第一行设置内容类型:

I have a webpage dynamically created via Python. Its purpose is to provide images, so the first line sets the content type:

Content-Type: image/png

我想设置http标头,特别是缓存控制,但我不太清楚如何作为内容类型不是html,所以我确定我不能把html样式标题放进去。

I would like to set http headers, specifically cache controlling, but I'm not too sure how as the content type is not html, so I'm sure I cant put html style headers into it.

编辑:代码简单地开始:

The code starts simply:

#!/usr/bin/python
# -*- coding: UTF-8 -*-
import string, sys, math, os
print("Content-Type: image/png\n")


推荐答案

Cache-Control,Content-Type等是HTTP标头,而不是html样式标题。无论内容类型如何,您都可以使用它们。

Cache-Control, Content-Type and the like are HTTP headers, not "html style headers". You can use them regardless of the content-type.

这篇关于如何设置具有不同内容类型的http标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆