本文翻译自:How are parameters sent in an HTTP POST request?

In an HTTP GET request, parameters are sent as a query string : 在HTTP GET请求中,参数作为查询字符串发送:

http://example.com/page?parameter=value&also=another

In an HTTP POST request, the parameters are not sent along with the URI. 在HTTP POST请求中,参数不会与URI一起发送。

Where are the values? 价值在哪里? In the request header? 在请求标头中? In the request body? 在请求正文中? What does it look like? 它是什么样子的?


#1楼

参考:https://stackoom.com/question/z3Qg/如何在HTTP-POST请求中发送参数


#2楼

Form values in HTTP POSTs are sent in the request body, in the same format as the querystring. HTTP POST中的表单值以与查询字符串相同的格式在请求正文中发送。

For more information, see the spec . 有关更多信息,请参见规范 。


#3楼

The content is put after the HTTP headers. 内容放在HTTP标头之后。 The format of an HTTP POST is to have the HTTP headers, followed by a blank line, followed by the request body. HTTP POST的格式为具有HTTP标头,后跟空白行,然后是请求正文。 The POST variables are stored as key-value pairs in the body. POST变量作为键值对存储在主体中。

You can see this in the raw content of an HTTP Post, shown below: 您可以在HTTP Post的原始内容中看到这一点,如下所示:

POST /path/script.cgi HTTP/1.0
From: frog@jmarshall.com
User-Agent: HTTPTool/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 32home=Cosby&favorite+flavor=flies

You can see this using a tool like Fiddler , which you can use to watch the raw HTTP request and response payloads being sent across the wire. 您可以使用Fiddler之类的工具来查看此信息,该工具可用于观察通过网络发送的原始HTTP请求和响应有效负载。


#4楼

You cannot type it directly on the browser URL bar. 您不能直接在浏览器URL栏上键入它。

You can see how POST data is sent on the Internet with Live HTTP Headers for example. 例如,您可以查看如何使用实时HTTP标头在Internet上发送POST数据。 Result will be something like that 结果将是这样的

http://127.0.0.1/pass.php
POST /pass.php HTTP/1.1Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Referer: http://127.0.0.1/pass.php
Cookie: passx=87e8af376bc9d9bfec2c7c0193e6af70; PHPSESSID=l9hk7mfh0ppqecg8gialak6gt5
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 30
username=zurfyx&pass=password

Where it says 它说的地方

Content-Length: 30username=zurfyx&pass=password

will be the post values. 将是职位价值。


#5楼

The values are sent in the request body, in the format that the content type specifies. 值以内容类型指定的格式在请求正文中发送。

Usually the content type is application/x-www-form-urlencoded , so the request body uses the same format as the query string: 通常,内容类型为application/x-www-form-urlencoded ,因此请求正文使用与查询字符串相同的格式:

parameter=value&also=another

When you use a file upload in the form, you use the multipart/form-data encoding instead, which has a different format. 当您使用表单上载文件时,将改用multipart/form-data编码,格式不同。 It's more complicated, but you usually don't need to care what it looks like, so I won't show an example, but it can be good to know that it exists. 它更复杂,但是您通常不需要关心它的外观,因此我不会显示示例,但是知道它的存在可能会很好。


#6楼

The default media type in a POST request is application/x-www-form-urlencoded . POST请求中的默认媒体类型为application/x-www-form-urlencoded This is a format for encoding key-value pairs. 这是用于编码键值对的格式。 The keys can be duplicate. 密钥可以重复。 Each key-value pair is separated by an & character, and each key is separated from its value by an = character. 每个键值对均以&字符分隔,每个键与其值之间以=字符分隔。

For example: 例如:

Name: John Smith
Grade: 19

Is encoded as: 编码为:

Name=John+Smith&Grade=19

This is placed in the request body after the HTTP headers. 它放在HTTP标头之后的请求正文中。

如何在HTTP POST请求中发送参数?相关推荐

  1. nGrinder中快速编写groovy脚本03-在GET请求中发送参数

    在GET请求脚本中添加添加信息头.cookies和自定义参数,有两种方式: 一种是在UI界面添加后自动生成脚本,一种是直接在脚本中添加. 一.通过UI界面添加 通过 UI 设置:脚本 -> 新建 ...

  2. php curl form-data,在php curl multipart / form-data请求中发送一个文件和json数据

    我正在尝试在PHP的curl请求中上传文件和json数据 . 请求在命令行中使用curl正常工作 . 这是命令行中的curl请求: curl -v --basic -u'username' -F fi ...

  3. ajax get怎么传参数值,如何使用jQuery在GET请求中传递参数

    我应该如何在jQuery Ajax请求中传递查询字符串值?我目前按照以下方式执行它们,但我确信有一种更简洁的方法,不需要我手动编码. $.ajax({ url: "ajax.aspx?aja ...

  4. java获取jsp页面参数_jsp页面中获取servlet请求中的参数方法总结

    jsp页面中获取servlet请求中的参数的办法详解 在JAVA WEB应用中,如何获取servlet请求中的参数,并传递给跳转的JSP页面?例如访问http://localhost:8088/bbs ...

  5. SpringMVC无法获取请求中的参数的问题的调查与解决(1)

    SpringMVC无法获取请求中的参数的问题的调查与解决(1) 参考文章: (1)SpringMVC无法获取请求中的参数的问题的调查与解决(1) (2)https://www.cnblogs.com/ ...

  6. gin ajax 获取请求参数,go的gin框架从请求中获取参数的方法

    前言: go语言的gin框架go里面比较好的一个web框架, github的start数超过了18000.可见此框架的可信度 如何获取请求中的参数 假如有这么一个请求: POST   /post/te ...

  7. 获取get请求中的参数

    需要获取get请求中的参数,将参数一一保存到数据库 方法一(只适合参数较少的情况): 使用 String a = request.getParameter("参数名");不适合参数 ...

  8. 获取http请求中的参数控制器给jsp传递数据的方式

    这里写自定义目录标题 获取http请求中的参数 直接参数名获取 通过对象的方式获取 通过Servlet API方式获取 当请求中的参数和方法中参数名不一致 直接在url中获取参数的方式 控制器给jsp ...

  9. 在jsp页面如何获取servlet请求中的参数的办法

    在JAVA WEB应用中,如何获取servlet请求中的参数 ,并传递给跳转的JSP页面?例如访问http://localhost:8088/bbs?id=1 当执行这个bbs servlet时,将u ...

最新文章

  1. 【linux】Valgrind工具集详解(十三):Helgrind(线程错误检测器)
  2. python计算平方面积_python中求平方
  3. Java中UDP协议的基本原理和简单用法
  4. [vue] 说说你对单向数据流和双向数据流的理解
  5. [CTO札记]从Cloud Computing看战略决策:想做、能做与可做 -
  6. C++语言基础 —— 控制结构
  7. c++中的new_面试中常见的C语言与C++区别的问题
  8. android linux 优化,【「Android」UE手游研发中,如何做好Android内存优化?】|Linux|DEX|腾讯游戏|_傻大方...
  9. c 调用matlab.m文件,ubuntu系统下C++调用matlab程序的方法详解
  10. Codeforces 466E Information Graph
  11. 解决Rational Rose找不到suite objects.dll文件的问题
  12. 乐max2 android9,辣评烩:乐Max 2即将升级EUI 6.0 基于安卓7.0!
  13. html css 实现发票(付款申请书)模板
  14. Shapley_Value全解析与公式推导
  15. 人脸识别算法DeepFace论文解读
  16. android 11.0禁用电源键(屏蔽关机短按长按事件)
  17. 手动压缩Outlook PST和OST文件
  18. Java—求绝对值(选择结构)
  19. GTX960M搭建《深度学习图像识别技术》所需的环境
  20. 基于改进YOLOv5的挖机铲斗缺陷检测系统(源码&教程)

热门文章

  1. Android .classpath文件的作用
  2. 阿里P7面试官告诉你:3-5年以上的Android开发如何深入进阶?Android中高级开发必须掌握哪些?
  3. 深copy 和 浅copy 解析
  4. Android 修改Progressbar 旋转速度
  5. java doc 编写
  6. 算法:枚举法---kotlin
  7. java 1.7 新io 实践 NIO2
  8. adb 提示adb server version(31) doesn't match this client(40) 解决办法
  9. java 反射详解通俗易懂
  10. flex 单独一行_Flex网页布局一CSS弹性伸缩盒子语法教程