本博客转载自:http://www.cnblogs.com/dinghanhua/p/5646435.html

1. Content-Type的类型

content-type:在Request Headers里,告诉服务器我们发送的请求信息是哪种格式的。

1.1 content-type:application/x-www-form-urlencoded

默认的。如果不指定content-type,默认使用此格式。
参数格式:key1=value1&key2=value2

1.2 content-type:application/json

参数为json格式

{

 "key1":"value1",

 "key2":"value2"

}

1.3 content-type:multipart/form-data

上传文件用这种格式
发送的请求示例:
【JMeter】HTTP请求之content-type

2. 不同的content-type如何输入参数

2.1 content-type:application/x-www-form-urlencoded

参数可以在Parameters或Body Data里输入,格式不同,如下图所示。
这两个参数输入的tab页只能使用一个,某一个有数据后不能切换到另一个。

Parameters:
【JMeter】HTTP请求之content-type
Body Data:
【JMeter】HTTP请求之content-type

2.2 content-type:application/json

首先添加信息头管理。
【JMeter】HTTP请求之content-type
信息头编辑页面,点击添加,输入content-type application/json
【JMeter】HTTP请求之content-type
在http请求,Body Data中输入json格式的参数
【JMeter】HTTP请求之content-type

2.3 content-type:multipart/form-data

在http请求编辑页面,选中Use multipart/form-data for POST
Parameters中输入除了上传的文件以外的参数:参数名和参数值
Files Upload中上传文件,参数名和MIME类型
【JMeter】HTTP请求之content-type

相关文章:

  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2021-12-16
  • 2021-10-16
  • 2022-12-23
  • 2022-02-28
猜你喜欢
  • 2022-12-23
  • 2021-11-11
  • 2022-02-14
  • 2021-09-29
  • 2022-12-23
  • 2021-04-18
  • 2021-10-12
相关资源
相似解决方案