content

2018-11-09 admin

content是什么

什么是content,HTTP Content-* headers parsing

content使用教程帮助文档

content

HTTP Content-* headers parsing.

NPM Version Build Status Dependencies

Lead Maintainer - Eran Hammer

Table of Contents

  • Installation
  • Usage
    • type(header)
    • disposition(header)

Installation

Install via NPM.

$ npm install content

Usage

content allows to parse HTTP Content-* headers, currently based on the rules established in both RFC 7231 Section 3.1.1.1 and RFC 6266 Section 4.1.

type(header)

Generates an object containing the associated mime-type and the boundary (if specified).

Content.type('application/json; some=property; and="another"');
// { mime: 'application/json' }

Content.type('application/json; boundary=asdf');
// { mime: 'application/json', boundary: 'asdf' }

If the header is invalid (malformed) or missing required data, such as a multipart/form-data header missing its boundary, it returns an HTTP Bad Request error.

disposition(header)

Generates an object containing the details related to the Content-Disposition header for the form-data content type with support for utf8 encoding.

Content.disposition('form-data; name="file"; filename=file.jpg');
// { name: 'file', filename: 'file.jpg' }

Content.disposition('form-data; name="file"; filename*=utf-8\'en\'with%20space');
// { name: 'file', filename: 'with space' }

If the header is invalid (malformed, invalid or missing properties) or is empty/missing, it returns an explanatory error.

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-44932.html

文章标题:content

相关文章
contents
contents是什么 什么是contents,Table of contents generator. contents官网:官网 contents源码仓库:源码仓库 contents下载地址:点此下载 点此下载2 contents使...
2018-11-29
How do I clear the contents of a div without innerHTML = "";
Myles Gray提出了一个问题:How do I clear the contents of a div without innerHTML = “”;,或许与您遇到的问题类似。 回答者Alnitak给出了该问题的处理方式: If yo...
2018-04-28
不换https,使用CSP(Content-Security-Policy)解决/缓解运营商dns劫持问题
The HTTP Content-Security-Policy response header allows web site administrators to control resources the user agent is a...
2018-06-05
在contenteditable占位符-焦点事件的问题
David提出了一个问题:Placeholder in contenteditable - focus event issue,或许与您遇到的问题类似。 回答者Tim Down给出了该问题的处理方式: You may need to man...
2018-03-26
content 内容生成技术2
计数器效果可是说是content的重中之重, 此功能非常强大、实用, 且不具有可替代性, 甚至可以实现连js都不好实现的效果. 这个地方放慢节奏, 细细品味. 先来个例子体验一下: .reset { counter-reset:...
2018-04-18
如何移动光标到最后contenteditable实体
Vito Gentileavsej提出了一个问题:How to move cursor to end of contenteditable entity,或许与您遇到的问题类似。 回答者CommunityVito Gentile给出了该问题...
2018-03-27
Contexts and methods for communication between the browser action, background scripts, and content scripts of chrome extensions?
mowwwalker提出了一个问题:Contexts and methods for communication between the browser action, background scripts, and content scr...
2018-04-26
在contenteditable精确拖放
ROMANIA_engineerChaseMoskal提出了一个问题:Precise Drag and Drop within a contenteditable,或许与您遇到的问题类似。 回答者ChaseMoskal给出了该问题的处理方式...
2018-03-27
contenteditable,设置插入的文本的末尾(跨浏览器)
Josh Crozier提出了一个问题:contenteditable, set caret at the end of the text (cross-browser),或许与您遇到的问题类似。 回答者Tim Down给出了该问题的处理方...
2018-03-20
Error parsing XHTML: The content of elements must consist of well-formed character data or markup
Communityluciaengel提出了一个问题:Error parsing XHTML: The content of elements must consist of well-formed character data or ma...
2018-04-17
回到顶部