Closed rplati closed 4 years ago
Seems Rserve convert the boundary string to lower case when write the body
content-type
atrribute. Example:
curl -v \
-X POST \
-H "Content-Type: multipart/form-data; boundary=AAAAA" \
-d $'--AAAAA\r\nContent-Disposition: form-data; name="example"\r\n\r\ntest\r\n--AAAAA--\r\n' \
http://127.0.0.1:8001
From the Rserve:
HEADERS:
Request-Method: POST
Host: 127.0.0.1:8001
User-Agent: curl/7.69.1
Accept: */*
Content-Type: multipart/form-data; boundary=AAAAA
Content-Length: 76
QUERY:
NULL
BODY:
raw [1:76] 2d 2d 41 41 ...
- attr(*, "content-type")= chr "multipart/form-data; boundary=aaaaa"
JMeter use uppercase symbols in the boundary. parse_multipart_body
tries to exact match it.
But Content-Type
header is ok. So we should use it.
With inst/examples/echo/app.R
from the #139:
curl -v -H "Content-Type: multipart/form-data; boundary=AAAAA" -d $'--AAAAA\r\nContent-Disposition: form-data; name="example"\r\n\r\ntest\r\n--AAAAA--\r\n' http://127.0.0.1:8080/echo
* Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> POST /echo HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.69.1
> Accept: */*
> Content-Type: multipart/form-data; boundary=AAAAA
> Content-Length: 76
>
* upload completely sent off: 76 out of 76 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-type: application/json
< Server: RestRserve/0.2.1
< Content-length: 322
<
* Connection #0 to host 127.0.0.1 left intact
{"path":"/echo","headers":{"content-length":"76","host":"127.0.0.1:8080","user-agent":"curl/7.69.1","accept":"*/*","content-type":"multipart/form-data; boundary=AAAAA"},"parameters":{"query":{},"body":{"example":"test"},"path":[]},"body":{"attributes":{"content-type":"multipart/form-data; boundary=aaaaa"},"rtpye":"raw"}}
@rplati, can you test again with dev
branch? To install use the following command:
remotes::install_github("rexyai/RestRserve@dev")
@artemklevtsov, I can confirm that the issue has been resolved, thank you!
@rplati on CRAN now
Hi, first of all thanks for your work on this package! I got it working and it looks very promising.
I was unable to test my API with JMeter due to tests failing when the API accepts multipart/form data.
I suspect this might be because the boundary that JMeter uses that does not start with double dash signs (--). It seems
parse_multipart_body
cannot handle that. When I submit the same call with Postman (boundary starts with --), everything works.Partial JMeter log: