Jmeter:HTTP 请求问题 returns java.net.URISyntaxException

Jmeter : Issue with HTTP request returns java.net.URISyntaxException

我正在使用我们的测试应用程序生成的 RSS 提要来验证我们的网站上是否有任何损坏的链接。

当我在经过一些预处理(拆分 URL 以提取协议、主机、域)后在 HTTP 采样器中使用这些 URL 时,大多数 URL的工作正常,但我在一些随机案例中遇到问题,如下所述。

例如: 下面提到的 URLs 抛出 URI 异常。下面提到的这些 URL 中突出显示的文本之间的 分隔符 not 似乎是一个普通的连字符。这是一些特殊的字符,我想需要特殊处理。

来自提要URL失败

https://abc.xyz.com/article/worksheet-development-规划—经理-preparation-10200/download/

https://abc.xyz.com/article/worksheet-development-规划—工人-preparation-10201/download/

来自断言侦听器的 JMeter 结果

See link below for JMeter Result from Assertion Listener

URL 被编码了一些意想不到的字符

你是对的,这个 — 符号需要是 URL-encoded,你的 URL 路径应该看起来像

article%252Fworksheet-development-planning%25E2%2580%2594manager-preparation-10200%252Fdownload%252F

JMeter 提供 __urlencode() function which can perform URL-encoding of the passed parameter on the fly so you can use it directly in the "Path" field of the HTTP Request 采样器,例如:

${__urlencode(/article/worksheet-development-planning—manager-preparation-10200/download/)}

查看 Apache JMeter Functions - An Introduction 文章以了解有关 JMeter 函数概念的更多信息。