JoeDog / siege

Siege is an http load tester and benchmarking utility
GNU General Public License v3.0
5.91k stars 386 forks source link

(urls.txt), POST and multipart/form-data #144

Closed ghost closed 5 years ago

ghost commented 5 years ago

I tried using POST in urls.txt, but it does not work:

(uri)/upload POST < path/to/file

and several things like this. Whereas GET works.

But i got no uploaded File.

Besides i tried:

me@u1:~$ siege -T "multipart/form-data;boundary=123456" "http://127.0.0.1:9501/upload POST < /home/me/testfile1.jpg" -g

but this gives:

IS ASCII: FALSE
POST /upload.html HTTP/1.0
Host: 127.0.0.1:9501
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/4.0.4
Connection: close
Content-type: image/jpeg
Content-length: 3201

I do not get the headers / upload anyway as Content-type: multipart/form-data;boundary=123456

I tried several files and commands 😕

So, how to upload multipart/form-data and all in all several uploads (more than one file), and lastly via urls.txt, too?

ghost commented 5 years ago

I would like to reference this: #139 and #45

ghost commented 5 years ago

Hmm

siege --version gives 4.0.4, installed via apt on ubuntu 18.04.1

Corrected release is 4.0.4 rc3

I will check this at home.

Ok, i have copied load.c and version.c to sources and build 4.0.4rc3, now something works, but only on console-side:

me@u1:~$ siege -T "multipart/form-data; boundary=----WebKitFormBoundarygSh4QkZB1NophVRp" "http://127.0.0.1:9501/upload POST < /home/me/testfile2.gif" -g
POST /upload.html HTTP/1.0
Host: 127.0.0.1:9501
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/4.0.4rc3
Connection: close
Content-type: multipart/form-data; boundary=----WebKitFormBoundarygSh4QkZB1NophVRp
Content-length: 320

My server does not work here.

tcpdump

Thats the original request with content, by google chrome (this works):

POST /upload.html HTTP/1.1
Host: 127.0.0.1:9501
Connection: keep-alive
Content-Length: 3529
Cache-Control: max-age=0
Origin: http://127.0.0.1:9501
Upgrade-Insecure-Requests: 1
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarypBBPRNgAKgpVe15g
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: http://127.0.0.1:9501/test.html
Accept-Encoding: gzip, deflate
Accept-Language: de,de-DE;q=0.9,en;q=0.8,zh-CN;q=0.7,zh-HK;q=0.6,zh;q=0.5
Cookie: somecookie=sometext

------WebKitFormBoundarypBBPRNgAKgpVe15g
Content-Disposition: form-data; name="fileToUpload"; filename="test.gif"
Content-Type: image/gif

GIF89aP.D....eh..f..`Ti.h...bh1....2g.h.i.6e2.e.......g.gj..h^q...%4.f..............4h............f.....i........i.......h......5....h........34....3f...fZ._.......4........0..i....5.0....QR.i...0..h..h3...ih.......3.h..f.......i...5.444..g.h...0.h..h....g.f........W..f.2h.........g..............T32................00...32f........3..e.........i.........3...3../2.}.
.......M1.......6....5..2./O..J....2....G...D....3....*.....3.w...6..M..        ..o .......I...$....e4R...2..x....3f..X.....%...JT........$.............3.....t....xg...*.. -------> AND SO ON
------WebKitFormBoundarypBBPRNgAKgpVe15g
Content-Disposition: form-data; name="submit"

Upload Image
------WebKitFormBoundarypBBPRNgAKgpVe15g--

Now curl file upload (this works, too)

POST /upload.html HTTP/1.1
Host: 127.0.0.1:9501
User-Agent: curl/7.58.0
Accept: */*
Content-Length: 3420
Content-Type: multipart/form-data; boundary=------------------------c66a37cf8aba7c08
Expect: 100-continue

.--------------------------c66a37cf8aba7c08
Content-Disposition: form-data; name="data"; filename="test.gif"
Content-Type: image/gif

GIF89aP.D....eh..f..`Ti.h...bh1....2g.h.i.6e2.e.......g.gj..h^q...%4.f..............4h............f.....i........i.......h......5....h........34....3f...fZ._.......4........0..i....5.0....QR.i...0..h..h3...ih.......3.h..f.......i...5.444..g.h...0.h..h....g.f........W..f.2h.........g..............T32................00...32f........3..e.........i.........3...3../2.}.
.......M1.......6....5..2./O..J....2....G...D....3....*.....3.w...6..M..        ..o .......I...$....e4R...2..x....3f..X.....%...JT........$.............3.....t....xg...*.....0i...d....V=..,..........K.........M.L...+H..D.....@.I.aV..WS.....z.......:X...8.....q..........A%.TT...`...f... ."........ -------> AND SO ON
--------------------------c66a37cf8aba7c08--

and now siege (works not)

again, done by: siege -T "multipart/form-data; boundary=----WebKitFormBoundarygSh4QkZB1NophVRp" "http://127.0.0.1:9501/upload POST < /home/me/test.gif" -g

POST /upload.html HTTP/1.0
Host: 127.0.0.1:9501
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/4.0.4rc3
Connection: close
Content-type: multipart/form-data; boundary=----WebKitFormBoundarygSh4QkZB1NophVRp
Content-length: 3235

GIF89aP.D....eh..f..`Ti.h...bh1....2g.h.i.6e2.e.......g.gj..h^q...%4.f..............4h............f.....i........i.......h......5....h........34....3f...fZ._.......4........0..i....5.0....QR.i...0..h..h3...ih.......3.h..f.......i...5.444..g.h...0.h..h....g.f........W..f.2h.........g..............T32................00...32f........3..e.........i.........3...3../2.}.
.......M1.......6....5..2./O..J....2....G...D....3....*.....3.w...6..M..        ..o .......I...$....e4R...2..x....3f..X.....%...JT........$.............3.....t....xg...*.....0i...d....V=..,..........K.........M.L...+H..D.....@.I.aV..WS.....z.......:X...8.....q..........A%.TT...`...f... ."..........$wvH5?..)..>..4.......$./..Y..,. ...#.. ....I...."..T..}&..sL.N..3.. ^.!d.b..z..3.. ...........>...\..}..S.}........?>...!..... -------> AND SO ON

Question:

Why siege has no kind of form-data content-handling

------WebKitFormBoundarypBBPRNgAKgpVe15g
Content-Disposition: form-data; name="someName"; filename="test.gif"
Content-Type: image/gif

So, why does #139 work and mine not?

Can you help, please?

ghost commented 5 years ago

no response

SaeedArisha commented 2 years ago

@

no response

Were you able to find somthing?

muayyad-alsadi commented 1 year ago

So, why does https://github.com/JoeDog/siege/issues/139 work and mine not?

you error is

ValueError: boundary missed for Content-Type: multipart/form-data                                                      │

his version works because the boundary is part of his data file

------123456
Content-Disposition: form-data; name="result"

result-data
------123456--