{"id":10020827,"date":"2025-06-14T00:14:32","date_gmt":"2025-06-13T16:14:32","guid":{"rendered":"https:\/\/itmax.cn\/?p=10020827"},"modified":"2025-06-14T00:14:32","modified_gmt":"2025-06-13T16:14:32","slug":"%e5%9b%9b%e7%a7%8d%e6%96%b9%e6%a1%88%e8%a7%a3%e5%86%b3%e6%b5%8f%e8%a7%88%e5%99%a8%e5%9c%b0%e5%9d%80%e6%a0%8f%e9%a2%84%e8%a7%88txt%e6%96%87%e6%9c%ac%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98content-type-tex","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10020827","title":{"rendered":"\u56db\u79cd\u65b9\u6848\u89e3\u51b3\u6d4f\u89c8\u5668\u5730\u5740\u680f\u9884\u89c8txt\u6587\u672c\u4e71\u7801\u95ee\u9898Content-Type: text\/plain;\u6ca1\u6709charset=utf-8"},"content":{"rendered":"<h2>\u95ee\u9898\u63cf\u8ff0<\/h2>\n<ul>\n<li>\u524d\u6bb5\u65f6\u95f4\uff0c\u7b14\u8005\u63a5\u624b\u4e86\u4e00\u4e2a\u8001\u9879\u76ee<\/li>\n<li>\u5176\u4e2d\u7528\u6237\u4f1a\u4e0a\u4f20\u4e00\u4e9b\u8d44\u6e90\uff0c\u6bd4\u5982\u56fe\u7247\u3001\u89c6\u9891\u5565\u7684\uff0c\u5176\u4e2d\u8fd8\u6709txt\u6587\u672c\u6587\u6863<\/li>\n<li>\u7528\u6237\u63d0\u51fa\uff0c\u9700\u8981\u518d\u52a0\u4e0a\u4e00\u4e2atxt\u6587\u672c\u9884\u89c8\u7684\u529f\u80fd<\/li>\n<li>\u7b14\u8005\u770b\u4e86\u4e00\u4e0b\u4ee3\u7801\uff0c\u539f\u672c\u7684\u56fe\u7247\u3001\u89c6\u9891\u9884\u89c8\u529f\u80fd\uff0c\u662f\u4f7f\u7528iframe\u5b9e\u73b0\u7684<\/li>\n<li>\u53ea\u9700\u8981\u628a\u540e\u7aef\u8fd4\u56de\u7684\u6587\u672c\u8d44\u6e90\u7684url\u4e22\u5230iframe\u7684src\u91cc\u9762\uff0c\u5c31\u80fd\u591f\u81ea\u52a8\u7ed9\u6e32\u67d3\u51fa\u6765<\/li>\n<li>\u7ed3\u679c\uff0c\u7b14\u8005\u8fd9\u6837\u64cd\u4f5c\u4ee5\u540e\uff0c\u76f4\u63a5\u4e71\u7801\u4e86\uff0c\u5982\u4e0b\u56fe\uff1a<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"386\" height=\"204\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdjUxx\" alt=\"\" title=\"\"><\/p>\n<ul>\n<li>\u4f46\u662f\u8fd9\u4e2atxt\u4e0b\u8f7d\u4e0b\u6765\uff0c\u6253\u5f00\u662f\u6ca1\u6709\u95ee\u9898\u7684\uff0c\u5982\u4e0b\u56fe<\/li>\n<\/ul>\n<p><img decoding=\"async\" width=\"444\" height=\"255\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdjUxy\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<ul>\n<li>\u8fd9\u91cc\uff0c\u4e3a\u4e86\u65b9\u4fbf\u5927\u5bb6\u770b\u6548\u679c\uff0c\u7b14\u8005\u7528\u81ea\u5df1\u7684\u670d\u52a1\u5668\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4e71\u7801\u7684txt\u6587\u672c\u8fde\u63a5<\/li>\n<li>\u4e71\u7801\u6587\u672c\u94fe\u63a5\uff0c\u70b9\u51fb\u770b\u6548\u679c\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=zAa3FZ17Wr%2FfhQP%2FZgIi7g%3D%3D.g938ZNj7IgT3tLuxjw%2B%2B8Ub%2BwyPUeYKJ%2BC5byjYWSKkLcc0HuNrGTtqxJ9YhFkHj\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/ashuai.work\/api\/stream.txt<\/a><\/li>\n<\/ul>\n<h2>\u95ee\u9898\u5206\u6790<\/h2>\n<p>\u6211\u4eec\u770b\u4e00\u4e0b\u63a7\u5236\u53f0\uff0c\u54cd\u5e94\u5934\u7684<code>Content-Type<\/code>\uff0c\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"586\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdjUxz\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h3>\u5177\u4f53\u539f\u56e0\u2014\u2014Content-Type: text\/plain;\u6ca1\u6709charset=utf-8<\/h3>\n<ul>\n<li><strong>\u5728\u8fd9\u4e2a\u8bf7\u6c42\u7684\u54cd\u5e94\u5934\u4e2d\uff0cContent-Type: text\/plain;<\/strong><\/li>\n<li><strong>\u7f3a\u5c11charset=utf-8\uff0c\u7f3a\u5c11\u4e86\u7f16\u7801\u5b57\u7b26\u96c6\uff0c\u5bfc\u81f4\u6d4f\u89c8\u5668\u6e32\u67d3\u4e71\u7801<\/strong><\/li>\n<li>\u8981\u662fHTTP \u54cd\u5e94\u5934\u4e2d\u53ea\u6307\u5b9a\u00a0<code>Content-Type: text\/plain<\/code>\u00a0<\/li>\n<li>\u800c\u6ca1\u6709\u660e\u786e\u8bbe\u7f6e\u5b57\u7b26\u96c6\uff08\u5982\u00a0<code>charset=utf-8<\/code>\uff09<\/li>\n<li>\u56e0\u4e3a\u6d4f\u89c8\u5668\u9700\u8981\u77e5\u9053\u5982\u4f55\u89e3\u7801\u63a5\u6536\u5230\u7684\u6587\u672c\u6570\u636e\uff0c\u82e5\u65e0\u6307\u5b9a\u5b57\u7b26\u96c6\uff0c\u6d4f\u89c8\u5668\u4f1a\u5c1d\u8bd5\u81ea\u52a8\u731c\u6d4b\u5b57\u7b26\u7f16\u7801<\/li>\n<li>\u800c\u4e14\uff0c\u4e0d\u540c\u6d4f\u89c8\u5668\u7684\u9ed8\u8ba4\u7f16\u7801\u53ef\u80fd\u4e0d\u540c\uff0c\u6bd4\u5982\u6709\u7684\u9ed8\u8ba4 <code>ISO-8859-1<\/code>\uff0c\u6709\u7684\u53ef\u80fd\u5c1d\u8bd5 <code>UTF-8<\/code><\/li>\n<li>\u6700\u7ec8\u5bfc\u81f4\u53ef\u80fd\u51fa\u73b0\u4e71\u7801\u60c5\u51b5<\/li>\n<li>\u597d\u5427&#8230;<\/li>\n<li>\u90a3\u4e3a\u4f55\u6ca1\u6709<code>charset=utf-8<\/code>\u5462<\/li>\n<li>\u90a3\u662f\u56e0\u4e3a\u4e0a\u4f20<code>txt<\/code>\u6587\u4ef6\u7684\u65f6\u5019<\/li>\n<li>\u5c31\u6ca1\u6709<code>charset=utf-8<\/code><\/li>\n<li>\u8fd9\u662f\u524d\u7aef\u7684\u9505\u54af&#8230;<\/li>\n<\/ul>\n<pre><code class=\"js\">route.post('\/upload', upload.single('file'), async (req, res) =&gt; {\n    try {\n        if (!req.file) {\n            return res.status(400).json({ error: '\u6ca1\u6709\u6587\u4ef6\u88ab\u4e0a\u4f20' });\n        }\n\n        console.log('req.file---&gt;', req.file)\n        \n        ......\n\n    } catch (error) {\n        console.error('\u4e0a\u4f20\u9519\u8bef:', error);\n        res.status(500).json({ error: '\u6587\u4ef6\u4e0a\u4f20\u5931\u8d25' });\n    }\n});<\/code><\/pre>\n<ul>\n<li>\u4e0a\u8ff0\u662f\u4e00\u4e2a\u540e\u7aef\u7684\u4e0a\u4f20\u63a5\u53e3<\/li>\n<li>\u5728\u63a5\u53e3\u4e2d\u6253\u5370\u524d\u7aef\u4f20\u9012\u8fc7\u6765\u7684file\u6587\u4ef6\u4fe1\u606f\u5982\u4e0b\uff1a<\/li>\n<\/ul>\n<pre><code class=\"js\">req.file---&gt; {\n  fieldname: 'file',\n  originalname: 'txt\u6587\u672c.txt',\n  encoding: '7bit',\n  mimetype: 'text\/plain',\n  buffer: &lt;Buffer e7 99 bd e6 97 a5 e4 be 9d e5 b1 b1 e5 b0 bd 0d 0a e9 bb 84 e6 b2 b3 e5 85 a5 e6 b5 b7 e6 b5 81 0d 0a e6 ac b2 e7 a9 b7 e5 8d 83 e9 87 8c e7 9b ae 0d ... 16 more bytes&gt;,\n  size: 66\n}<\/code><\/pre>\n<ul>\n<li>\u5728\u8fd9\u91cc\u6211\u4eec\u5c31\u53ef\u4ee5\u770b\u5230\uff0c<code>mimetype: 'text\/plain'<\/code>, \u8fd9\u91cc\uff0c\u5c31\u5df2\u7ecf\u5c11\u4e86\u5b57\u7b26\u96c6<code>utf-8<\/code><\/li>\n<li>\u540c\u65f6\uff0c\u6211\u4eec\u518d\u770b\u4e00\u4e0b\uff0c\u4e0a\u4f20\u63a5\u53e3\u7684\u8f7d\u8377\u5982\u4e0b\u56fe\uff1a<\/li>\n<\/ul>\n<p><img decoding=\"async\" width=\"723\" height=\"484\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdjUxA\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4\uff0c\u6700\u521d\u524d\u7aef\u4e0a\u4f20<code>txt<\/code>\u6587\u672c\u7684\u65f6\u5019\uff0c\u5c31\u6ca1\u6709\u6307\u5b9a<code>utf-8<\/code>\uff0c\u5bfc\u81f4\u540e\u7aef\u63a5\u6536\u6587\u4ef6\u7684\u65f6\u5019\uff0c\u4e5f\u6ca1\u6709\u7f16\u7801\uff0c\u81ea\u7136\u540e\u7eed\u90fd\u6ca1\u6709<code>utf-8<\/code>\uff0c\u6d4f\u89c8\u5668\u89e3\u6790\u4e5f\u5c31\u6709\u53ef\u80fd\u51fa\u95ee\u9898\u4e86&#8230;<\/p>\n<h2>\u89e3\u51b3\u65b9\u6848<\/h2>\n<p>\u77e5\u9053\u95ee\u9898\u539f\u56e0\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5236\u5b9a\u89e3\u51b3\u65b9\u6848\u4e86<\/p>\n<h3>\u65b9\u6848\u4e00 \u524d\u7aef\u4e0a\u4f20\u7684\u65f6\u5019\uff0c\u9488\u5bf9\u4e8etxt\u6587\u672c\u7c7b\u578b\u7684\uff0c\u8981\u989d\u5916\u6307\u5b9autf-8\u5b57\u7b26\u96c6\u7f16\u7801<\/h3>\n<p>\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"js\">const formData = new FormData();\nformData.append('file', file);\n\n\/\/ \u4f7f\u7528 fetch \u6216 axios \u4e0a\u4f20\nfetch('\/upload', {\n  method: 'POST',\n  body: formData,\n  headers: {\n    'Content-Type': 'text\/plain; charset=utf-8', \/\/ \u6307\u5b9a\u5b57\u7b26\u96c6utf-8\n  }\n});<\/code><\/pre>\n<h3>\u65b9\u6848\u4e8c \u540e\u7aef\u63a5\u53e3\u6307\u5b9autf-8<\/h3>\n<ul>\n<li>\u5047\u8bbe\u8fd9\u4e2a\u6587\u4ef6\u76f8\u5173\uff0c\u90fd\u662f\u5b58\u50a8\u5728<code>minio<\/code>\u4e0a\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u5b58<code>txt<\/code>\u6587\u4ef6\u7684\u65f6\u5019<\/li>\n<li>\u6307\u5b9a<code>charset=utf-8<\/code><\/li>\n<\/ul>\n<pre><code class=\"js\">\/\/ \u6587\u4ef6\u4e0a\u4f20\u63a5\u53e3\nroute.post('\/upload', upload.single('file'), async (req, res) =&gt; {\n\n    console.log('req.file---&gt;', req.file)\n\n    const fileName = req.file.originalname\n\n    const metaData = {\n        'Content-Type': 'Content-Type': 'text\/plain; charset=utf-8',\n        'Content-Disposition': 'inline'\n    };\n\n    await minioClient.putObject(bucketName, fileName, req.file.buffer, metaData);\n\n    res.json({\n        success: true,\n        fileName: fileName,\n        message: '\u6587\u4ef6\u4e0a\u4f20\u6210\u529f'\n    });\n});<\/code><\/pre>\n<p><em>\u5982\u679c\u662f\u7b80\u5355\u7684\u63a5\u53e3\uff0c\u53ef\u4ee5\u76f4\u63a5\u8bbe\u7f6e\u54cd\u5e94\u5934\uff0c\u5982\u4e0b\uff1a<\/em><\/p>\n<pre><code class=\"js\">\/\/ \u52a8\u6001\u8def\u7531\u4f20\u53c2\u65b9\u5f0f\uff0c\u901a\u8fc7params\u83b7\u53d6\u52a8\u6001\u53c2\u6570\nroute.get('\/stream.txt', (req, res) =&gt; {\n\n  \/\/ \u5b58\u50a8\u4e00\u4efdtxt\u6587\u4ef6\u7684\u8def\u5f84\n  let txtUrl = '.\/assets\/stream.txt'\n  const Myfilesize = fs.statSync(txtUrl).size\n\n  \/\/ \u6b64\u63a5\u53e3\u5141\u8bb8\u8de8\u57df\n  res.header('Access-Control-Allow-Origin', '*');\n\n  res.writeHead(200, { 'Content-Type': 'text\/plain' }); \/\/ \u7eaf\u6587\u672c\uff0c\u4e0d\u8bbe\u7f6e\u7f16\u7801\uff0c\u5bb9\u6613\u4e71\u7801\n  \/\/ res.writeHead(200, { 'Content-Type': 'text\/plain; charset=utf-8' }); \/\/ \u7eaf\u6587\u672c\uff0c\u8bbe\u7f6e\u7f16\u7801utf-8\uff0c\u89e3\u51b3\u4e71\u7801\u95ee\u9898\n\n  \/\/\u521b\u5efa\u53ef\u8bfb\u6d41 \u5f15\u5165\u6587\u4ef6\u6a21\u5757 const fs = require(&quot;fs&quot;)\n  let readStream = fs.createReadStream(txtUrl)\n\n  \/\/ \u5c06\u8bfb\u53d6\u7684\u7ed3\u679c\u4ee5\u7ba1\u9053pipe\u6d41\u7684\u65b9\u5f0f\u8fd4\u56de\u7ed9\u524d\u7aef\n  readStream.pipe(res);\n})<\/code><\/pre>\n<h3>\u65b9\u6848\u4e09 nginx\u5904\u7406\uff0c\u6307\u5b9acharset=utf-8<\/h3>\n<p>\u5047\u8bbe\uff0c\u6211\u662f\u901a\u8fc7<code>nginx<\/code>\u53cd\u5411\u4ee3\u7406\u7684\u6587\u4ef6\u670d\u52a1\uff0c\u6307\u5b9a\u6587\u672c\u5b57\u7b26\u96c6\u96c6\u5408<\/p>\n<pre><code class=\"js\">location \/file\/ {\n    proxy_pass http:\/\/file-server.com\/;\n    \n    proxy_hide_header Content-Type;\n    add_header Content-Type &quot;text\/plain; charset=utf-8&quot; always;\n}<\/code><\/pre>\n<p>\u6216<\/p>\n<pre><code class=\"js\"># \u7279\u6b8a\u5904\u7406 .txt \u6587\u4ef6 \u91cd\u5199Content-Type \u54cd\u5e94\u5934\nlocation ~* ^\/file\/(.+\/.txt)$ {\n    # \u53bb\u9664\u524d\u7f00 \/file\/ \u540e\u8f6c\u53d1\n    proxy_pass http:\/\/file-server.com\/$1;\n\n    proxy_hide_header Content-Type;\n    add_header Content-Type &quot;text\/plain; charset=utf-8&quot; always;\n}<\/code><\/pre>\n<h3>\u65b9\u6848\u56db \u4e0d\u4f7f\u7528iframe\uff0c\u6362\u6210\u76f4\u63a5\u53d1\u8bf7\u6c42\uff0c\u642d\u914dpre\u6807\u7b7e<\/h3>\n<p>\u6548\u679c\u56fe<\/p>\n<p><img decoding=\"async\" width=\"609\" height=\"556\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdjUxB\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4ee3\u7801<\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot;&gt;\n\n&lt;head&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\n    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;\n    &lt;title&gt;Document&lt;\/title&gt;\n    &lt;script src=&quot;https:\/\/cdn.bootcdn.net\/ajax\/libs\/axios\/1.9.0\/axios.js&quot;&gt;&lt;\/script&gt;\n    &lt;style&gt;\n        iframe {\n            width: 360px;\n            height: 200px;\n        }\n\n        pre {\n            white-space: pre-wrap;\n            text-align: left;\n        }\n    &lt;\/style&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n    &lt;!-- iframe\u4e71\u7801 --&gt;\n    &lt;iframe src=&quot;https:\/\/ashuai.work\/api\/stream.txt&quot; frameborder=&quot;0&quot;&gt;&lt;\/iframe&gt;\n\n    &lt;!-- \u76f4\u63a5\u8bf7\u6c42\u6587\u672c\u5185\u5bb9\uff0c\u653e\u7f6e\u5728pre\u6807\u7b7e\u91cc --&gt;\n    &lt;pre&gt;&lt;\/pre&gt;\n    &lt;script&gt;\n        let pre = document.querySelector('pre')\n        axios.get('https:\/\/ashuai.work\/api\/stream.txt').then((res) =&gt; {\n            console.log('res', res.data)\n            pre.innerHTML = res.data\n        })\n    &lt;\/script&gt;\n&lt;\/body&gt;\n\n&lt;\/html&gt;<\/code><\/pre>\n<blockquote><p>\u5177\u4f53\u9009\u62e9\u54ea\u79cd\u89e3\u51b3\u65b9\u6848\uff0c\u5927\u5bb6\u6839\u636e\u81ea\u5df1\u5b9e\u9645\u60c5\u51b5\u64cd\u4f5c\u5373\u53ef<\/p><\/blockquote>\n<h2>\u77e5\u8bc6\u70b9\u56de\u987e\uff0c\u5e38\u89c1\u7684Content-Type<\/h2>\n<p>\u4e0a\u8ff0\u7684\u6848\u4f8b\uff0c\u662f\u9488\u5bf9\u4e8e<code>Content-Type: text\/plain;<\/code> \u6dfb\u52a0 <code>charset=utf-8<\/code> \u5b57\u7b26\u96c6\uff0c\u5728\u6b64\uff0c\u6211\u4eec\u56de\u987e\u4e00\u4e0b\uff0c\u5e38\u89c1\u7684\u5185\u5bb9\u7c7b\u578b\u6709\u54ea\u4e9b<\/p>\n<blockquote><p>\u5e38\u89c1\u7684 <code>Content-Type<\/code>\uff08\u5185\u5bb9\u7c7b\u578b\uff09\u7528\u4e8e\u6807\u8bc6 HTTP \u8bf7\u6c42\u6216\u54cd\u5e94\u4e2d\u4f20\u8f93\u7684\u6570\u636e\u683c\u5f0f\u3002\u4e0d\u540c\u7684 <code>Content-Type<\/code> \u5bf9\u5e94\u4e0d\u540c\u7684\u6570\u636e\u7f16\u7801\u65b9\u5f0f\uff0c\u7528\u6765\u6b63\u786e\u89e3\u6790\u6570\u636e\uff0c\u5f88\u91cd\u8981\uff01<\/p><\/blockquote>\n<hr>\n<h3><strong>1. \u6587\u672c\u7c7b\u578b\uff08Text Types\uff09<\/strong><\/h3>\n<table>\n<thead>\n<tr>\n<th>Content-Type<\/th>\n<th>\u7528\u9014<\/th>\n<th>\u793a\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>text\/plain<\/code><\/td>\n<td>\u7eaf\u6587\u672c\uff08\u9ed8\u8ba4\u65e0\u683c\u5f0f\uff09<\/td>\n<td><code>.txt<\/code> \u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td><code>text\/html<\/code><\/td>\n<td>HTML \u6587\u6863<\/td>\n<td>\u7f51\u9875\uff08<code>&lt;html&gt;...&lt;\/html&gt;<\/code>\uff09<\/td>\n<\/tr>\n<tr>\n<td><code>text\/css<\/code><\/td>\n<td>CSS \u6837\u5f0f\u8868<\/td>\n<td><code>.css<\/code> \u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td><code>text\/csv<\/code><\/td>\n<td>CSV \u8868\u683c\u6570\u636e<\/td>\n<td><code>.csv<\/code> \u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td><code>text\/javascript<\/code><\/td>\n<td>JavaScript \u4ee3\u7801\uff08\u65e7\u6807\u51c6\uff0c\u63a8\u8350 <code>application\/javascript<\/code>\uff09<\/td>\n<td><code>.js<\/code> \u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td><code>text\/xml<\/code><\/td>\n<td>XML \u6570\u636e<\/td>\n<td><code>.xml<\/code> \u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td><code>text\/markdown<\/code><\/td>\n<td>Markdown \u6587\u6863<\/td>\n<td><code>.md<\/code> \u6587\u4ef6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\uff1a<\/p>\n<pre><code class=\"http\">Content-Type: text\/plain; charset=utf-8 <\/code><\/pre>\n<blockquote><p>\u4e00\u822c\u5efa\u8bae\u6587\u672c\u7c7b\u578b\u6700\u597d\u6307\u5b9a\u4e00\u4e0b\u5b57\u7b26\u96c6\u4e3autf-8\uff0c\u4ee5\u9632\u51fa\u73b0\u4e71\u7801\u7684\u60c5\u51b5<\/p><\/blockquote>\n<hr>\n<h3><strong>2. \u5e94\u7528\u7c7b\u578b\uff08Application Types\uff09<\/strong><\/h3>\n<table>\n<thead>\n<tr>\n<th>Content-Type<\/th>\n<th>\u7528\u9014<\/th>\n<th>\u793a\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>application\/json<\/code><\/td>\n<td>JSON \u6570\u636e\uff08API \u5e38\u7528\uff09<\/td>\n<td><code>{&quot;name&quot;: &quot;John&quot;}<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>application\/xml<\/code><\/td>\n<td>XML \u6570\u636e\uff08\u6bd4 <code>text\/xml<\/code> \u66f4\u4e25\u683c\uff09<\/td>\n<td><code>&lt;name&gt;John&lt;\/name&gt;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>application\/javascript<\/code><\/td>\n<td>JavaScript \u4ee3\u7801<\/td>\n<td><code>.js<\/code> \u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td><code>application\/pdf<\/code><\/td>\n<td>PDF \u6587\u6863<\/td>\n<td><code>.pdf<\/code> \u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td><code>application\/zip<\/code><\/td>\n<td>ZIP \u538b\u7f29\u6587\u4ef6<\/td>\n<td><code>.zip<\/code> \u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td><code>application\/octet-stream<\/code><\/td>\n<td>\u4e8c\u8fdb\u5236\u6d41\uff08\u9ed8\u8ba4\u4e0b\u8f7d\u7c7b\u578b\uff09<\/td>\n<td>\u4efb\u610f\u4e8c\u8fdb\u5236\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td><code>application\/x-www-form-urlencoded<\/code><\/td>\n<td>\u8868\u5355 URL \u7f16\u7801\uff08\u9ed8\u8ba4\u8868\u5355\u63d0\u4ea4\uff09<\/td>\n<td><code>name=John&amp;age=20<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>application\/xml-dtd<\/code><\/td>\n<td>XML DTD \u5b9a\u4e49<\/td>\n<td><code>.dtd<\/code> \u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td><code>application\/ld+json<\/code><\/td>\n<td>JSON-LD\uff08\u7ed3\u6784\u5316\u6570\u636e\uff09<\/td>\n<td>SEO \u6570\u636e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code class=\"http\">Content-Type: application\/json; charset=utf-8\nContent-Type: application\/x-www-form-urlencoded<\/code><\/pre>\n<hr>\n<h3><strong>3. \u591a\u5a92\u4f53\u7c7b\u578b\uff08Multimedia Types\uff09<\/strong><\/h3>\n<table>\n<thead>\n<tr>\n<th>Content-Type<\/th>\n<th>\u7528\u9014<\/th>\n<th>\u793a\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>image\/jpeg<\/code><\/td>\n<td>JPEG \u56fe\u7247<\/td>\n<td><code>.jpg<\/code>, <code>.jpeg<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>image\/png<\/code><\/td>\n<td>PNG \u56fe\u7247<\/td>\n<td><code>.png<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>image\/gif<\/code><\/td>\n<td>GIF \u52a8\u56fe<\/td>\n<td><code>.gif<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>image\/webp<\/code><\/td>\n<td>WebP \u56fe\u7247<\/td>\n<td><code>.webp<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>image\/svg+xml<\/code><\/td>\n<td>SVG \u77e2\u91cf\u56fe<\/td>\n<td><code>.svg<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>audio\/mpeg<\/code><\/td>\n<td>MP3 \u97f3\u9891<\/td>\n<td><code>.mp3<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>audio\/wav<\/code><\/td>\n<td>WAV \u97f3\u9891<\/td>\n<td><code>.wav<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>video\/mp4<\/code><\/td>\n<td>MP4 \u89c6\u9891<\/td>\n<td><code>.mp4<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>video\/webm<\/code><\/td>\n<td>WebM \u89c6\u9891<\/td>\n<td><code>.webm<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code class=\"http\">Content-Type: image\/jpeg\nContent-Type: video\/mp4<\/code><\/pre>\n<hr>\n<h3><strong>4. \u8868\u5355\u6570\u636e\uff08Form Data\uff09<\/strong><\/h3>\n<table>\n<thead>\n<tr>\n<th>Content-Type<\/th>\n<th>\u7528\u9014<\/th>\n<th>\u793a\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>multipart\/form-data<\/code><\/td>\n<td>\u6587\u4ef6\u4e0a\u4f20\uff08\u542b\u4e8c\u8fdb\u5236\u6570\u636e\uff09<\/td>\n<td><code>&lt;form enctype=&quot;multipart\/form-data&quot;&gt;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>application\/x-www-form-urlencoded<\/code><\/td>\n<td>\u666e\u901a\u8868\u5355\u63d0\u4ea4\uff08\u952e\u503c\u5bf9\uff09<\/td>\n<td><code>&lt;form&gt;<\/code> \u9ed8\u8ba4\u65b9\u5f0f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u793a\u4f8b<\/strong>\uff1a<\/p>\n<pre><code class=\"http\">Content-Type: multipart\/form-data; boundary=----WebKitFormBoundaryABC123<\/code><\/pre>\n<hr>\n<h3><strong>5. \u5176\u4ed6\u5e38\u89c1\u7c7b\u578b<\/strong><\/h3>\n<table>\n<thead>\n<tr>\n<th>Content-Type<\/th>\n<th>\u7528\u9014<\/th>\n<th>\u793a\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>font\/woff<\/code><\/td>\n<td>WOFF \u5b57\u4f53<\/td>\n<td><code>.woff<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>font\/woff2<\/code><\/td>\n<td>WOFF2 \u5b57\u4f53<\/td>\n<td><code>.woff2<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>application\/vnd.ms-excel<\/code><\/td>\n<td>Excel \u65e7\u683c\u5f0f<\/td>\n<td><code>.xls<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet<\/code><\/td>\n<td>Excel (XLSX)<\/td>\n<td><code>.xlsx<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>application\/msword<\/code><\/td>\n<td>Word \u65e7\u683c\u5f0f<\/td>\n<td><code>.doc<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>application\/vnd.openxmlformats-officedocument.wordprocessingml.document<\/code><\/td>\n<td>Word (DOCX)<\/td>\n<td><code>.docx<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr>\n<h2><strong>\u603b\u7ed3<\/strong><\/h2>\n<table>\n<thead>\n<tr>\n<th>\u7c7b\u522b<\/th>\n<th>\u5e38\u89c1 <code>Content-Type<\/code><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>\u6587\u672c<\/strong><\/td>\n<td><code>text\/plain<\/code>, <code>text\/html<\/code>, <code>text\/css<\/code>, <code>text\/csv<\/code><\/td>\n<\/tr>\n<tr>\n<td><strong>JSON\/XML<\/strong><\/td>\n<td><code>application\/json<\/code>, <code>application\/xml<\/code><\/td>\n<\/tr>\n<tr>\n<td><strong>\u8868\u5355<\/strong><\/td>\n<td><code>multipart\/form-data<\/code>, <code>application\/x-www-form-urlencoded<\/code><\/td>\n<\/tr>\n<tr>\n<td><strong>\u56fe\u7247<\/strong><\/td>\n<td><code>image\/jpeg<\/code>, <code>image\/png<\/code>, <code>image\/svg+xml<\/code><\/td>\n<\/tr>\n<tr>\n<td><strong>\u89c6\u9891\/\u97f3\u9891<\/strong><\/td>\n<td><code>video\/mp4<\/code>, <code>audio\/mpeg<\/code><\/td>\n<\/tr>\n<tr>\n<td><strong>\u6587\u4ef6\u4e0b\u8f7d<\/strong><\/td>\n<td><code>application\/octet-stream<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u6d4f\u89c8\u5668\u4f1a\u9ed8\u8ba4MIME \u7c7b\u578b\u55c5\u63a2<\/h3>\n<ul>\n<li>\u5f53\u670d\u52a1\u5668\u6ca1\u6709\u660e\u786e\u6307\u5b9a <code>Content-Type<\/code> \u6216\u8005\u8bbe\u7f6e\u4e0d\u5b8c\u6574\uff08\u4f8b\u5982\u7f3a\u5c11\u5b57\u7b26\u7f16\u7801\u4fe1\u606f\uff09\u65f6\uff0c\u6d4f\u89c8\u5668\u901a\u5e38\u4f1a\u5c1d\u8bd5\u8fdb\u884c <code>MIME<\/code> \u7c7b\u578b\u55c5\u63a2\uff08<code>MIME Type Sniffing<\/code>\uff09\u3002<\/li>\n<li>\u5b83\u901a\u8fc7\u68c0\u67e5\u5185\u5bb9\u7684\u5b9e\u9645\u6570\u636e\u6765\u731c\u6d4b\u6b63\u786e\u7684 <code>MIME<\/code> \u7c7b\u578b\u548c\u5b57\u7b26\u7f16\u7801\uff0c\u4ee5\u4fbf\u6b63\u786e\u5730\u663e\u793a\u5185\u5bb9\u3002<\/li>\n<li>\u4e0d\u8fc7\uff0c\u53ef\u80fd\u4e0d\u592a\u591f\u7528\uff0c\u6240\u4ee5\u5927\u5bb6\u6700\u597d\uff0c\u8fd8\u662f\u6307\u5b9a<code>content-type<\/code><\/li>\n<li>\u6240\u4ee5\uff1a\u6b63\u786e\u8bbe\u7f6e <code>Content-Type<\/code> \u53ef\u4ee5\u907f\u514d\u4e71\u7801\u3001\u89e3\u6790\u9519\u8bef\u7b49\u95ee\u9898\uff0c\u7279\u522b\u662f\u5728\u6587\u4ef6\u4e0a\u4f20\u3001\u63a5\u53e3\u4ea4\u4e92\u65f6\u975e\u5e38\u91cd\u8981\uff01<\/li>\n<\/ul>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000046652239\">https:\/\/segmentfault.com\/a\/1190000046652239<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898\u63cf\u8ff0 \u524d\u6bb5\u65f6\u95f4\uff0c\u7b14\u8005\u63a5\u624b\u4e86\u4e00\u4e2a\u8001\u9879\u76ee \u5176\u4e2d\u7528\u6237\u4f1a\u4e0a\u4f20\u4e00\u4e9b\u8d44\u6e90\uff0c\u6bd4\u5982\u56fe\u7247\u3001\u89c6\u9891\u5565\u7684\uff0c\u5176\u4e2d\u8fd8\u6709txt\u6587\u672c\u6587\u6863  [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10020827","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10020827"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020827\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10020827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10020827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10020827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}