Apache Benchmark:流在多部分请求中意外结束

时间:2018-08-27 10:41:38

标签: apache benchmarking apachebench

我遇到了一个与如何使用apache基准测试提供多部分请求有关的问题:

这是我的命令:

$ ab -n 100 -c 5 \
 -T 'multipart/form-data; boundary=1234567890' \
 -H 'Authorization: bearer 435cd0ef-6afb-4c2a-acfe-e64b7dc81a5f' \
 -p post_data.txt \
 -v 4 \
 http://localhost:8081/fitxers/raw/b64

我正在尝试发送此邮递员生成的curl摘录代码:

curl -X POST \
  http://localhost:8081/fitxers/raw/b64 \
  -H 'Authorization: bearer <token...>' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F 'metadata={"name":"kkk", "app":"ghdsjhd"}' \
  -F content=@ffc.txt

我从服务器收到此错误消息:

{
   "timestamp":"2018-08-27T10:28:32.426+0000",
   "status":500,
   "error":"Internal Server Error",
   "message":"Failed to parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: Stream ended unexpectedly",
   "path":"/fitxers/raw/b64"
}

基本上:

  

流意外结束

我的post_data.txt文件内容是:

--1234567890
Content-Disposition: form-data; name="metadata"

string
--1234567890
Content-Disposition: form-data; name="content"; filename="myfile.txt"
Content-Type: text/plain

dHh0IGZpbGU=
--1234567890--

这里有完整的输出:

$ ab -n 1 -c 1 -T 'multipart/form-data; boundary=1234567890' -H 'Authorization: bearer 435cd0ef-6afb-4c2a-acfe-e64b7dc81a5f' -p post_data.txt -v 4 http://localhost:8081/fitxers/raw/b64
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)...INFO: POST header == 
---
POST /fitxers/raw/b64 HTTP/1.0
Content-length: 207
Content-type: multipart/form-data; boundary=1234567890
Authorization: bearer 435cd0ef-6afb-4c2a-acfe-e64b7dc81a5f
Host: localhost:8081
User-Agent: ApacheBench/2.3
Accept: */*


---
LOG: header received:
HTTP/1.1 500 
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: application/json;charset=UTF-8
Date: Mon, 27 Aug 2018 11:05:32 GMT
Connection: close

{"timestamp":"2018-08-27T11:05:32.497+0000","status":500,"error":"Internal Server Error","message":"Failed to parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: Stream ended unexpectedly","path":"/fitxers/raw/b64"}
WARNING: Response code not 2xx (500)
..done


Server Software:        
Server Hostname:        localhost
Server Port:            8081

Document Path:          /fitxers/raw/b64
Document Length:        297 bytes

Concurrency Level:      1
Time taken for tests:   0.075 seconds
Complete requests:      1
Failed requests:        0
Non-2xx responses:      1
Total transferred:      598 bytes
Total body sent:        442
HTML transferred:       297 bytes
Requests per second:    13.37 [#/sec] (mean)
Time per request:       74.787 [ms] (mean)
Time per request:       74.787 [ms] (mean, across all concurrent requests)
Transfer rate:          7.81 [Kbytes/sec] received
                        5.77 kb/s sent
                        13.58 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    1   0.0      1       1
Processing:    74   74   0.0     74      74
Waiting:       57   57   0.0     57      57
Total:         75   75   0.0     75      75

0 个答案:

没有答案