Abi*_*vam 7 java put urlencode jmeter
我正在尝试使用Jmeter记录我的Web客户端 - 服务器通信.配置Jmeter和浏览器以记录应用程序之后.从客户端到服务器发出post请求时,会发生以下错误.知道如何编码正在记录的URL吗?
java.net.URISyntaxException: Illegal character in query at index 238: http://localhost:8080/updateBoxCorrectionInstantly?examKey=16-17-%3ECBSE-%3ETERM%20I-%3ESA1-%3EVI-%3EScience-%3EA&studentName=AMOGH%20YOGESH%20KALE&studentRollno=3&studentND=-1&sheetName=cb8e806b32e9d670698655e0d2da10e3_img001210.jpg&box={%22$center%22:%22(66.0,%202253.0)%22,%22$conf%22:%22H%22,%22$corrected%22:true,%22$isAdminCorrected%22:true,%22$correction%22:%22-%22,%22$isDrawn%22:false,%22coords%22:[36,2214,96,2292],%22isTitle%22:false,%22pos%22:%22-%22,%22pred%22:%22-%22,%22boxTypeId%22:0,%22score%22:1}
at java.net.URI$Parser.fail(URI.java:2829)
at java.net.URI$Parser.checkChars(URI.java:3002)
at java.net.URI$Parser.parseHierarchical(URI.java:3092)
at java.net.URI$Parser.parse(URI.java:3034)
at java.net.URI.<init>(URI.java:595)
at java.net.URL.toURI(URL.java:949)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:232)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1075)
at org.apache.jmeter.protocol.http.proxy.Proxy.run(Proxy.java:212)
Run Code Online (Sandbox Code Playgroud)
具体而言,该异常与 URI 中的大括号有关:
/updateBoxCorrectionInstantly?<...>_img001210.jpg&box={
Run Code Online (Sandbox Code Playgroud)
大括号被认为是不安全的:
其他字符是不安全的,因为已知网关和其他传输代理有时会修改这些字符。这些字符是“{”、“}”、“|”、“\”、“^”、“~”、“[”、“]”和“`”。所有不安全字符必须始终编码在 URL 中。
因此,您可以将所有实例替换为{,%7B并将所有实例替换}为%7D。我的猜测是记录器没有对它们进行编码,因为大括号不是“特殊”字符(它们只是“不安全”),而 URI 解析器不喜欢它们。所以你可以将其视为 JMeter 记录器中的错误。因此,最小的解决方案是将Path设置为:
/updateBoxCorrectionInstantly?examKey=16-17-%3ECBSE-%3ETERM%20I-%3ESA1-%3EVI-%3EScience-%3EA&studentName=AMOGH%20YOGESH%20KALE&studentRollno=3&studentND=-1&sheetName=cb8e806b32e9d670698655e0d2da10e3_img001210.jpg&box=%7B%22$center%22:%22(66.0,%202253.0)%22,%22$conf%22:%22H%22,%22$corrected%22:true,%22$isAdminCorrected%22:true,%22$correction%22:%22-%22,%22$isDrawn%22:false,%22coords%22:[36,2214,96,2292],%22isTitle%22:false,%22pos%22:%22-%22,%22pred%22:%22-%22,%22boxTypeId%22:0,%22score%22:1%7D
Run Code Online (Sandbox Code Playgroud)
然而,我认为一个更优雅的解决方案是将所有参数(超过标记?)保存在参数部分,这有几个优点:
这是我如何创建此请求的屏幕截图:
因为Method设置为GET,所以所有参数都将成为 URL 的一部分,但它们将被正确编码,因此发送方式如下:
| 归档时间: |
|
| 查看次数: |
6090 次 |
| 最近记录: |