简体   繁体   English

Apache Jmeter忽略了帖体

[英]Apache Jmeter ignoring post body

I have a problem emulating a Http request in JMeter. 我在JMeter中模拟Http请求时遇到问题。

The basic task is to make JMeter emulate a request made in firefox, and then use that as the basis of a performance test. 基本任务是让JMeter模拟在firefox中发出的请求,然后将其用作性能测试的基础。 However, i am having problems getting JMeter to include the post-header body. 但是,我在让JMeter包含post-header主体方面遇到了问题。

Using fiddler, i recorded the request from firefox, which looks something like this. 使用fiddler,我记录了来自firefox的请求,看起来像这样。

POST http://*****:8001/XMLServlet?action=send HTTP/1.1
Host: *****
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Referer: http://*****:8001/XMLServlet
Cookie: JSESSIONID=YpvCQGvFWshb6yyNsZvWZzHLLknNMpXRJ36vR7p0jxSp41Q3zlbj!-409403047
Content-Type: multipart/form-data; boundary=---------------------------491299511942
Content-Length: 3125
-----------------------------491299511942
Content-Disposition: form-data; name="find"; filename="2010100010427.XML"
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE DDT PUBLIC "*****" "*****">
<Some XML file/>
-----------------------------491299511942
Content-Disposition: form-data; name="submit"

Send
-----------------------------491299511942--

I made a login request in JMeter which works fine, but the actual post isn't behaving as expected. 我在JMeter中发出了一个登录请求,但是实际的帖子没有按预期运行。

I am using the "Send file with request" option to send the file, i have chosen the POST method, and in Post Body(raw) i have added 我正在使用“发送文件请求”选项发送文件,我选择了POST方法,并在Post Body(raw)中添加了

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Host: *****
Connection: keep-alive
Referer: http://*****:8001/XMLServlet

I would expect this to be included in the final request, but when i look at fiddler after executing fiddler, this is the result: 我希望这可以包含在最终请求中,但是当我在执行fiddler后查看fiddler时,结果如下:

POST http://*****:8001/XMLServlet?action=send HTTP/1.1
Connection: keep-alive
Cookie: JSESSIONID=LdyTQGsGzg0bSvbTKhF3grPhBYTKnY2TJ3CzLdB3Fwp8K7r2z2zN!-409403047
Content-Length: 2034
Content-Type: multipart/form-data; boundary=_bm2tmf-3Nv071ZvyhFKaWOc4RixWE_dNyLk
Host: *****:8001
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.2.1 (java 1.5)

--_bm2tmf-3Nv071ZvyhFKaWOc4RixWE_dNyLk
Content-Disposition: form-data; name="find"; filename="2010100000484.XML"
Content-Type: text/xml
Content-Transfer-Encoding: binary

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE DDT PUBLIC "*****" "http://*****/sad.dtd">
<Some XML file/>

--_bm2tmf-3Nv071ZvyhFKaWOc4RixWE_dNyLk--

Why is JMeter ignoring the Post Body? 为什么JMeter忽略了Post Body? And more importantly: How do i fix it? 更重要的是:我该如何解决?

What you added to POST body are HTTP headers, not body. 您添加到POST正文的是HTTP标头,而不是正文。 Headers can't be setupped in HTTP Request sampler. 无法在HTTP请求采样器中设置标头。 To send them, you should add HTTP Header Manager with all those headers. 要发送它们,您应该添加带有所有这些标头的HTTP标头管理器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM