我在JMeter中模拟Http请求时遇到问题。
基本任务是让JMeter模拟在firefox中发出的请求,然后将其用作性能测试的基础。 但是,我在让JMeter包含后标题主体方面遇到了问题。
使用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--
我在JMeter中发出了一个登录请求,但是实际的帖子没有按预期运行。
我正在使用“发送带请求的文件”选项来发送文件,我选择了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
我希望这可以包含在最终请求中,但是当我在执行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--
为什么JMeter忽略了Post Body?更重要的是:我该如何解决?
答案 0 :(得分:4)
您添加到POST正文的内容是HTTP标头,而不是正文。无法在HTTP请求采样器中设置标头。要发送它们,您应该添加HTTP Header Manager所有这些标题。