Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request with multipart/form-data is not being accepted at endpoint #626

Closed
Korysam15 opened this issue Apr 28, 2023 · 8 comments · Fixed by #727
Closed

request with multipart/form-data is not being accepted at endpoint #626

Korysam15 opened this issue Apr 28, 2023 · 8 comments · Fixed by #727
Labels
bug Something isn't working

Comments

@Korysam15
Copy link

Korysam15 commented Apr 28, 2023

All,

I am having an issue where I am trying to upload a file with size 36M and it is not reaching my endpoint at all. However, if I send another file with the same format that is of size 57K it hits the endpoint and succeeds. I've been reading into the stream_threshold() and how it is set to a default value of 1MB. I increased this value to 45MB by using the code below:

app.stream_threshold(45 * 1024 * 1024);

but I'm not having any luck.

This is what the endpoint definition looks like:

CROW_ROUTE(app, "/v1/job/<string>/event/<string>/upload") .methods(crow::HTTPMethod::POST) ([this](const crow::request& req, string job_id, string id) { }

I am sending the following request:

curl <ip addr>:5002/v1/job/${job_id}/event/${event_id}/upload -i -F 'file=@cases/1.8.0/test.nc;'

When I use the verbose flag I receive the following output:

> POST /v1/job/5cccf134-4fa7-413d-9e55-25ab70131c71/event/82bbc650-bcb9-45e1-b7a2-41ca01cdf89b/upload HTTP/1.1
> Host: <host name>
> User-Agent: curl/7.87.0
> Accept: */*
> Content-Length: 37751200
> Content-Type: application/netcdf; boundary=------------------------a9c1e72da9dd7fc2
> Expect: 100-continue
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 100 Continue
HTTP/1.1 100 Continue

* Recv failure: Connection reset by peer
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer

Here is the log output from the CROW Server when I make this request:

(2023-04-28 17:40:37) [DEBUG   ] 0x7fe870000f80 timer added: 0x7fe8b4ba0410 2
(2023-04-28 17:40:37) [DEBUG   ] 0x7fe870000f80 timer cancelled: 0x7fe8b4ba0410 2
(2023-04-28 17:40:37) [DEBUG   ] task_timer cancelled: 0x7fe8b4ba0410 2
(2023-04-28 17:40:37) [DEBUG   ] 0x7fe870000f80 from read(1) with description: "invalid HTTP method"
(2023-04-28 17:40:37) [DEBUG   ] 0x7fe870000f80 is_reading 0 is_writing 0
(2023-04-28 17:40:37) [DEBUG   ] 0x7fe870000f80 delete (idle) (queue length: 0)
(2023-04-28 17:40:37) [DEBUG   ] 0x7fe870000f80 timer cancelled: 0x7fe8b4ba0410 2
(2023-04-28 17:40:37) [DEBUG   ] task_timer cancelled: 0x7fe8b4ba0410 2

Note I took out the IP address information from the output of the curl request.

I have also tried increasing the max time to allow the transfer to take and that didn't help either.

Any help is appreciated.

@kiner-shah
Copy link
Contributor

kiner-shah commented May 15, 2023

This looks similar to issue #558 #607

@The-EDev The-EDev added the bug Something isn't working label May 15, 2023
@Korysam15
Copy link
Author

@kiner-shah it is very similar. I didn't see a solution to that one besides downgrading crow. I downgraded to v1.0+3 and that seemed to fix the issue.

@lkoeller
Copy link

I think the issue is due to HTTP header "Expect: 100-continue" sent by curl automatically if uploaded file is bigger than some fixed size.

I can reproduce with :

curl -k -v --header "Content-Type: application/json" --header "Transfer-Encoding: chunked" --header "Accept: application/json" --header "Expect: 100-continue" -X POST https://myserver/api/xxx -d @data.json

By forcing Expect:100-continue, I have the same issue : from read(1) with description: "invalid HTTP method"

When I remove the header, and send a small file, it works !

curl -k -v --header "Content-Type: application/json" --header "Transfer-Encoding: chunked" --header "Accept: application/json" -X POST https://myserver/api/xxx -d "{}"

@lkoeller
Copy link

I just revert the commit

0aff1bc Prevent HTTP pipelining which Crow doesn't support.

And the issue is solved !

It seems that fixing this vulnerability leads to critical regression

@Korysam15
Copy link
Author

@lkoeller did you make a merge request for this fix? If not could you?

@lkoeller
Copy link

lkoeller commented Jun 28, 2023 via email

@german1608
Copy link

Hello!

I'm facing this issue. Any updates on a fix?

@lkoeller
Copy link

lkoeller commented Aug 4, 2023 via email

bruvey37 added a commit to bruvey37/Crow that referenced this issue Dec 6, 2023
bruvey37 pushed a commit to bruvey37/Crow that referenced this issue Dec 6, 2023
gittiver pushed a commit that referenced this issue Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants