如何从jmeter中的响应标头读取值? [英] How to read a value from response header in jmeter?

查看:879
本文介绍了如何从jmeter中的响应标头读取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到以下标题作为响应: HTTP/1.1 200 OK 日期:2016年4月11日星期一10:36:10 GMT 内容-倾向:附件; filename = result.xml; x-xss-保护:1;模式=访问保持活动状态:超时= 5,最大= 100 我想从标题中读取文件名,如何使用正则表达式捕获此值?

I am getting following header in response : HTTP/1.1 200 OK Date: Mon, 11 Apr 2016 10:36:10 GMT content-disposition: attachment; filename=result.xml; x-xss-protection: 1; mode=access Keep-Alive: timeout=5, max=100 I want to read filename from header, how can I use regular expression to capture this value ?

推荐答案

  1. 添加正则表达式提取器 作为孩子返回上面标头的 HTTP请求
  2. 配置如下:

  1. Add Regular Expression Extractor as a child of the HTTP Request which returns above headers
  2. Configure it as follows:

  • 应用于:Main sample onlyMain sample and sub-samples,具体取决于标头是来自主响应还是嵌套响应
  • 要检查的字段:Response Headers.这一点超级很重要
  • 参考名称:任何有意义的内容,例如filename
  • 正则表达式:filename=(.+?);
  • 模板:$1$

  • Apply to: Main sample only or Main sample and sub-samples depending on whether header comes in main response or nested responses
  • Field to check: Response Headers. This bit is super important
  • Reference Name: anything meaningful, i.e. filename
  • Regular Expression: filename=(.+?);
  • Template: $1$

在需要的情况下将提取的值引用为${filename}

Refer extracted value as ${filename} where required


  1. 参考文献:

  1. References:

  • Regular Expressions
  • Using RegEx (Regular Expression Extractor) With JMeter

这篇关于如何从jmeter中的响应标头读取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆