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

相关文章
ContentTools
ContentTools是什么 什么是ContentTools,A JS library for building WYSIWYG editors for HTML content ContentTools官网:官网 ContentToo...
2018-06-11
不换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
content 内容生成技术2
计数器效果可是说是content的重中之重, 此功能非常强大、实用, 且不具有可替代性, 甚至可以实现连js都不好实现的效果. 这个地方放慢节奏, 细细品味. 先来个例子体验一下: .reset { counter-reset:...
2018-04-18
在contenteditable精确拖放
ROMANIA_engineerChaseMoskal提出了一个问题:Precise Drag and Drop within a contenteditable,或许与您遇到的问题类似。 回答者ChaseMoskal给出了该问题的处理方式...
2018-03-27
在contenteditable占位符-焦点事件的问题
David提出了一个问题:Placeholder in contenteditable - focus event issue,或许与您遇到的问题类似。 回答者Tim Down给出了该问题的处理方式: You may need to man...
2018-03-26
如何移动光标到最后contenteditable实体
Vito Gentileavsej提出了一个问题:How to move cursor to end of contenteditable entity,或许与您遇到的问题类似。 回答者CommunityVito Gentile给出了该问题...
2018-03-27
What are the cons of using a contentEditable div rather than a textarea?
Jakub HamplBabiker提出了一个问题:What are the cons of using a contentEditable div rather than a textarea? ,或许与您遇到的问题类似。 回答者TML给...
2018-04-19
contenteditable,设置插入的文本的末尾(跨浏览器)
Josh Crozier提出了一个问题:contenteditable, set caret at the end of the text (cross-browser),或许与您遇到的问题类似。 回答者Tim Down给出了该问题的处理方...
2018-03-20
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
How can I use deflated/gzipped content with an XHR onProgress function?
Jimmy Sawczuk提出了一个问题:How can I use deflated/gzipped content with an XHR onProgress function?,或许与您遇到的问题类似。 回答者Jimmy Sawcz...
2018-04-12
回到顶部