JMeter - 无法使用 POST 变量发送 HTTP 请求? [英] JMeter - Trouble sending HTTP request with POST variable?

查看:45
本文介绍了JMeter - 无法使用 POST 变量发送 HTTP 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对从存档数据库中获取记录的 Java servlet 进行负载测试.

I am trying to load test a java servlet that fetches records from an archive database.

servlet 的工作原理如下:

The servlet works as follows:

  • 1-从 HTTP 标头中读取 post 变量
  • 2-使用变量查询数据库
  • 3-返回 XML

我已经设置了一个测试,我想用 post 变量触发 HTTP 请求,但是测试不起作用,J Meter 出现错误.

I have setup a test which I want to fire off HTTP requests with post variables however the test is not working, getting errors with J Meter.

屏幕截图 1 - 显示测试的结构

屏幕截图 2 - 显示我正在读取的 CSV 文件

我已将 CSV 文件放在保存我的测试计划的同一文件夹中!

I have placed the CSV file in the same folder that my test plan is saved in!

屏幕截图 3 - 显示 HTTP 请求

这是错误输出:

线程名称:线程组 1-1 示例开始:2012-11-20 10:35:27 GMT加载时间:0 延迟:0 字节大小:1113 标头大小(字节):0正文大小(以字节为单位):1113 样本计数:1 错误计数:1 响应代码:非 HTTP 响应代码:java.net.URISyntaxException 响应消息:非 HTTP 响应消息:IPv6 地址的预期右括号在索引 13:http://[http://sophos1.testserver.co.uk/servlet/archive]:61061/

Thread Name: Thread Group 1-1 Sample Start: 2012-11-20 10:35:27 GMT Load time: 0 Latency: 0 Size in bytes: 1113 Headers size in bytes: 0 Body size in bytes: 1113 Sample Count: 1 Error Count: 1 Response code: Non HTTP response code: java.net.URISyntaxException Response message: Non HTTP response message: Expected closing bracket for IPv6 address at index 13: http://[http://sophos1.testserver.co.uk/servlet/archive]:61061/

响应头:

HTTPSampleResult 字段:ContentType:DataEncoding:null

HTTPSampleResult fields: ContentType: DataEncoding: null

POST 请求

POST http://[http://sophos1.testserver.co.uk/servlet/archive]:61061/

POST data:


[no cookies]

返回的数据

java.net.URISyntaxException: Expected closing bracket for IPv6 address at index 13: http://[http://sophos1.testserver.co.uk/servlet/archive]:61061/
        at java.net.URI$Parser.fail(Unknown Source)
        at java.net.URI$Parser.failExpecting(Unknown Source)
        at java.net.URI$Parser.parseServer(Unknown Source)
        at java.net.URI$Parser.parseAuthority(Unknown Source)
        at java.net.URI$Parser.parseHierarchical(Unknown Source)
        at java.net.URI$Parser.parse(Unknown Source)
        at java.net.URI.<init>(Unknown Source)
        at java.net.URL.toURI(Unknown Source)
        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.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1064)
        at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:426)
        at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:255)
        at java.lang.Thread.run(Unknown Source)

请帮忙!

谢谢

推荐答案

Remove http:// from Server Name/IP field of your HTTP Request Sampler(在 HTTP 请求字段描述).

Remove http:// from Server Name / IP field of your HTTP Request Sampler (that's pointed in HTTP Request fields description).

在上面的描述中查看您生成的 POST 请求:

Look onto your generated POST request above in description:

POST Request
POST http://[http://sophos1.testserver.co.uk/servlet/archive]:61061/

改为如下配置您的 HTTP 请求:

Configure your HTTP Request as the following instead:

Server Name: sophos1.testserver.co.uk
Path: /servlet/archive
Implementation: Java

这篇关于JMeter - 无法使用 POST 变量发送 HTTP 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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