2016-06-28 413 views
0

当我试图将图片上传使用HTTP的POST方法利用JMeter,它投掷的错误如下Jmeter_响应错误,如:HTTP响应代码:405不允许的方法

采样请求的Web应用程序:

Size in bytes: 436 
Headers size in bytes: 335 
Body size in bytes: 101 
Sample Count: 1 
Error Count: 1 
Data type ("text"|"bin"|""): text 
Response code: 405 
Response message: Method Not Allowed 

Response headers: 
HTTP/1.1 405 Method Not Allowed 
Allow: GET, HEAD, OPTIONS, TRACE 
Content-Length: 101 
Content-Type: text/html 
Server: Microsoft-IIS/8.0 
X-Powered-By: ASP.NET 
Set-Cookie: ARRAffinity=a1634f39ccba9517317254d32be7078bb62c2877a947d85cab990f2708382045;Path=/;Domain=revflexsit.azurewebsites.net 
Date: Tue, 28 Jun 2016 10:04:41 GMT 


HTTPSampleResult fields: 
ContentType: text/html 
DataEncoding: null 

请求:

POST http://revflexsit.azurewebsites.net/#//testerprofile 

POST data: 
--8WPDqrXY5glD81_9CcLHn-xfOTrWvH4Dh4srjx 
Content-Disposition: form-data; name="profileUploadPhoto"; filename="Tulips.jpg" 
Content-Type: image/jpeg 
Content-Transfer-Encoding: binary 

<actual file content, not shown here> 
--8WPDqrXY5glD81_9CcLHn-xfOTrWvH4Dh4srjx-- 


[no cookies] 

Request Headers: 
Connection: keep-alive 
Content-Length: 621121 
Content-Type: multipart/form-data; boundary=8WPDqrXY5glD81_9CcLHn-xfOTrWvH4Dh4srjx; charset=US-ASCII 
Host: revflexsit.azurewebsites.net 
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_40) 

响应数据:

The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used. 

回答

2

服务器响应几乎是不言自明的,你不能让POST请求到该URL,只有GET,HEAD,OPTION和TRACE的。

为什么不使用HTTP(S) Test Script Recorder来记录您的测试场景并根据需要修改生成的测试“骨架”?

如果你还在渴望手动构建的情况下,寻找到了http://revflexsit.azurewebsites.net/网站,它似乎正确的请求看起来像:

  • 路径:/api/TesterProfile/UploadTesterProfile?Id=${YOUR_ID_HERE}&UpdateAdminId=0&dimensions=x,y,x,y
  • 文件上传:

    • 文件路径:图片的完整路径,您正在尝试上传
    • 参数名称:profileUploadPhoto
    • MIME类型:相关照片MIME Type

别忘了勾选 “使用的multipart/form-data的POST为” 框。

有关更详细的说明,请参阅How to Test Image Upload Functionality With JMeter

+0

谢谢你,我明白了.... –

相关问题