HTTP协议上传文件-协议

上传文件需要将form标签 的 ENCTYPE 属性设置为 multipart/form-data属性, 与

  1. application/x-www-form-urlencoded类型不同, 此类型专门设计用来上传文件, 而前者用来传输数据,

可以允许若干 控件域 同时上传其值,

每个域值使用 boundary 分割:

  1. <FORM ACTION="http://server.dom/cgi/handle"
  2. ENCTYPE="multipart/form-data"
  3. METHOD=POST>
  4. What is your name? <INPUT TYPE=TEXT NAME=submitter>
  5. What files are you sending? <INPUT TYPE=FILE NAME=pics>
  6. </FORM>
  1. The client might send back the following data:
  2.  
  3. Content-type: multipart/form-data, boundary=AaB03x
  4.  
  5. --AaB03x
  6. content-disposition: form-data; name="field1"
  7.  
  8. Joe Blow
  9. --AaB03x
  10. content-disposition: form-data; name="pics"; filename="file1.txt"
  11. Content-Type: text/plain
  12.  
  13. ... contents of file1.txt ...
  14. --AaB03x--

详解见:

http://www.faqs.org/rfcs/rfc1867.html

HTTP协议上传文件-boundary选取

  1. A
  2. boundary is selected that does not occur in any of the data. (This
  3. selection is sometimes done probabilisticly.)

需要不能再文件中出现, 但实践上不能扫描整个文件,再确定boundary, 所以往往是 生成一个随机值。

具有一定的概率性, 随着随机值的长度变化, 所以冲突概率很低。

HTTP协议下载文件-协议

下载报文头:

Content-Type: image/jpeg

Content-Disposition: inline;filename=hello.jpg

Content-Description: just a small picture of me

下载不要包括一个 头域:

Content-Disposition 属性是作为对下载文件的一个标识字段, 是对下载文件的显示方式的描述。

脚本设置方法:

http://blog.csdn.net/androidmi/article/details/7519243

HTTP协议下载文件-content-disposition

content-disposition来自于 MIME (http://www.faqs.org/rfcs/rfc1521.html)

此协议仅仅规定报文传输过程, 但是并没有规定,传输的内容对于接收端如何显示处理。

  1. [RFC 1521] specifies a standard format for encapsulating multiple
  2. pieces of data into a single Internet message. That document does not
  3. address the issue of presentation styles; it provides a framework for
  4. the interchange of message content, but leaves presentation issues
  5. solely in the hands of mail user agent (MUA) implementors.

http://www.rfc-editor.org/rfc/rfc1806.txt

此报文头content-disposition, 对报文体进行描述, 规定了接收端的显示处理行为。

此报文头的值有两种, attachment 和 inline, 分别表示保存 还是 直接显示。

  1. Two common ways of presenting multipart electronic messages are as a
  2. main document with a list of separate attachments, and as a single
  3. document with the various parts expanded (displayed) inline. The
  4. display of an attachment is generally construed to require positive
  5. action on the part of the recipient, while inline message components
  1. are displayed automatically when the message is viewed.

attachment and inline

  1. disposition := "Content-Disposition" ":"
  2. disposition-type
  3. *(";" disposition-parm)
  4.  
  5. disposition-type := "inline"
  6. / "attachment"
  7. / extension-token
  8. ; values are not case-sensitive
  9.  
  10. disposition-parm := filename-parm / parameter
  11.  
  12. filename-parm := "filename" "=" value;

disposition英文释义

http://www.ldoceonline.com/dictionary/disposition

dis‧po‧si‧tion formal

1 [countable usually singular] a particular type of character which makes someone likely to behave or react in a certain way [= temperament]

of a nervous/sociable/sensitive etc disposition (=having a nervous etc character)

The film is not suitable for people of a nervous disposition.

have a cheerful/sunny etc disposition (=have a happy character)

2 [singular] a tendency or willingness to behave in a particular way [= inclination]

have/show a disposition to do something

Neither side shows the slightest disposition to compromise.

disposition towards

Most children have a disposition towards obedience.

3 [countable usually singular] the position or arrangement of something in a particular place

disposition of

a map showing the disposition of American forces

4 [uncountable] formal the way in which something is dealt with or used

disposition of

A solicitor advised him as to the disposition of the money.

5 [uncountable and countable] law the act of formally giving property to someone:

the disposition of assets on death

content-disposition 中 disposition 的含义是

4 [uncountable] formal the way in which something is dealt with or used

disposition of

即 content-disposition === the disposition of the message content 对消息内容的处理方式, inline 直接展示, attachment 以附件方式存储。

HTTP协议上传boundary确定&下载content-disposition理解的更多相关文章

  1. http 协议上传文件multipart form-data boundary 说明--转载

    原文地址:http://xixinfei.iteye.com/blog/2002017 含义 ENCTYPE="multipart/form-data" 说明: 通过 http 协 ...

  2. Jmeter和LR上传文件和下载

    Jmeter和LR上传文件和下载 背景: 在某个申请业务中,需要上传附件文件,然后才能提交该申请 遇到的问题: 1,  在使用Jmeter或者LR进行录制时,无法录制到上传文件的请求,只能通过Fidd ...

  3. Android用http协议上传文件

    http协议上传文件一般最大是2M,比较适合上传小于两M的文件   [代码] [Java]代码   001import java.io.File;  002import java.io.FileInp ...

  4. c++使用http协议上传文件到七牛云服务器

    使用c++ http协议上传文件到七牛服务器时,比较搞的一点就是header的设置: "Content-Type:multipart/form-data;boundary=xxx" ...

  5. C# 应用 - 使用 HttpClient 发起上传文件、下载文件请求

    1. 示例代码 using System; using System.IO; using System.Net.Http; /// <summary> /// 下载文件 /// </ ...

  6. Java基础知识强化之网络编程笔记11:TCP之TCP协议上传文本文件

    1. TCP协议上传文本文件(客户端上传数据到服务器端) (1)客户端(上传数据到服务端) package cn.itcast_11; import java.io.BufferedReader; i ...

  7. Java ftp 上传文件和下载文件

    今天同事问我一个ftp 上传文件和下载文件功能应该怎么做,当时有点懵逼,毕竟我也是第一次,然后装了个逼,在网上找了一段代码发给同事,叫他调试一下.结果悲剧了,运行不通过.(装逼失败) 我找的文章链接: ...

  8. ie8 ajaxSubmit 上传文件提示下载

    转载 解决ie下ajaxsubmit上传文件提示下载文件问题 主要是应为放回类型为json,返回text/html

  9. C# FileStream进行FTP服务上传文件和下载文件

    定义FileStream类的操作类:操作类名: FtpUpDown 上传文件 /// <summary> /// 上传文件 /// </summary> /// <par ...

随机推荐

  1. iOS9 升级XCode7遇到的问题收集

    开发环境运行      各位可能会觉得,笔者在此还要讲开发环境的运行,是不是多此一举.其实并非如此,综合笔者这几年iOS开发经验的总结,运行新版本,特别是测试版本的Xcode是一个需要格外小心的事情, ...

  2. 在Windows7下启动MongoDB服务的解决方案

    1:首先去官网下载程序,我用的是1.4.3版本,地址: http://downloads.mongodb.org/win32/mongodb-win32-i386-1.4.3.zip 2:创建一个DB ...

  3. 在springmvc中,获取Connection接口

    ServletContext context = request.getSession().getServletContext();WebApplicationContext wac = WebApp ...

  4. Fling——K

    K. Fling Fling is a kind of puzzle games available on phone.This game is played on a board with 7 ro ...

  5. as3如何做出残影效果

    在页游中,时不时能看到人物做一些快速移动动作如冲刺时,有残影效果,强化了画面表现.实际人肉眼之所以能看到残影的效果,是因为观察到的物体会在人视线中残留几十毫秒时间,当运动物体运动太快时,人肉眼所见未能 ...

  6. oracle中删除表中某字段出现重复的信息 保留其中一条

    记得以前有个同事问过我这个,说是以前面试的时候碰到的问题,下面我介绍三种方法. 首先我们在这里创建一个测试表添加相应的测试数据. create table test  (id number,name ...

  7. HTML - 毛玻璃 滤镜 模糊

    css 秘密花园 http://dabblet.com/gist/d9f243ddd7dbffa341a4 场景,背景图片 + 毛玻璃遮盖 原理:利用background的cover特性,将毛玻璃的区 ...

  8. BizTalk动手实验(十三)EDI解决方案开发配置

    1 课程简介 通过本课程熟悉EDI解决文案的开发与配置,本动手实验步骤及内容采用微软官方SDK完成,学员在实验过程中结合官方教程来完成本实验 2 准备工作 从BizTalk安装目录的SDK中将EDI ...

  9. C++STL -- vector 使用

    vector是一种顺序容器. vector常用API: 现在一个个分析: 1. assign 这是一种赋值方法,但是会覆盖原来容器内的值. void assign( size_type num, co ...

  10. String-原型属性

    <script> /*将trim方法定义到字符串对象中 *使用字符串的原型属性来完成 *原型prototype:就是该对象的一个描述,该描述中如果添加新功能,那么该对象就具备这些新功能. ...