使用 JMeter 从响应头中提取位置 [英] Extract Location from Response Header with JMeter
本文介绍了使用 JMeter 从响应头中提取位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个字符串:
Location →/cochise/workflow/5c46e69364ddf300013412b5
如何使用 jmeter 提取最终的十六进制代码?
How do I extract the final hexadecimal code using jmeter?
推荐答案
使用以下配置添加 Regular Expression Extractor
后处理器作为您请求的子级:
Add a Regular Expression Extractor
post processor as a child of your request with below configurations:
- 适用于:
主样本和子样本
- 要检查的字段:
Response Headers
- 参考名称:
myVar
- 正则表达式:
位置:.+/(.*?)
- 模板:
$1$
- 匹配号:
1
- 默认值:
NOT_FOUND
- Apply to:
Main sample and sub-samples
- Field to check:
Response Headers
- Reference Name:
myVar
- Regular Expression:
Location: .+/(.*?)
- Template:
$1$
- Match No:
1
- Default Value:
NOT_FOUND
现在您可以使用包含十六进制值的 jmeter 变量 ${myVar}
.您可以在线程组级别添加查看结果树和调试采样器,以确保提取正确的值.
Now you can use jmeter variable ${myVar}
which contains hexadecimal value. You can add view results tree and debug sampler at thread group level to make sure you are extracting the right value.
参考资料
- 正则表达式来自 Jmeter 用户手册.
- 使用正则表达式使用 jmeter
- Regular expressions from Jmeter user manual.
- Using regex with jmeter
这篇关于使用 JMeter 从响应头中提取位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文