You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
❯ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/rust_study`
[2023-07-08T01:59:18Z INFO actix_server::builder] starting 8 workers
[2023-07-08T01:59:18Z INFO actix_server::server] Actix runtime found; starting in Actix runtime
[2023-07-08T01:59:26Z WARN rust_study] name length: 4
[2023-07-08T01:59:26Z INFO actix_web::middleware::logger] 127.0.0.1 "POST / HTTP/1.1" 200 13 "-""curl/8.1.2" 3.468221
Expected Behavior
log something like Form error: incomplete request
http-status code 400 not 200
Context
rfc-2616
When a Content-Length is given in a message where a message-body is allowed, its field value MUST exactly match the number of OCTETs in the message-body. HTTP/1.1 user agents MUST notify the user when an invalid length is received and detected.
the incomplete request should not be handled as normal. because:
not match http sepc
the handler does not have the Content-Length, it can not valid this by itself.
Possible Solution
take form as an example, check payload length after got
I encountered this issue last week. I'm just about to open an issue, and I just write here.
After some investigating I think the core problem is at Payload status passing. I submitted an PR #3068 to fixed. With your demo code, the output becomes:
[2023-07-10T07:35:53Z INFO actix_server::builder] starting 32 workers
[2023-07-10T07:35:53Z INFO actix_server::server] Actix runtime found; starting in Actix runtime
[2023-07-10T07:35:58Z WARN demo] Form error: Error that occur during reading payload: payload reached EOF before completing: Some(Kind(UnexpectedEof)).
[2023-07-10T07:35:58Z DEBUG actix_web::middleware::logger] Error in response: Payload(Incomplete(Some(Kind(UnexpectedEof))))
[2023-07-10T07:35:58Z INFO actix_web::middleware::logger] 127.0.0.1 "POST / HTTP/1.1" 409 0 "-" "curl/8.1.2" 3.143109
Steps to Reproduce (for bugs)
code
steps
cargo run
ctrl-c
stop thecurl
Current Behavior
Expected Behavior
Form error: incomplete request
Context
the incomplete request should not be handled as normal. because:
Content-Length
, it can not valid this by itself.Possible Solution
take form as an example, check payload length after got
actix-web/actix-web/src/types/form.rs
Lines 383 to 396 in ce3af77
The text was updated successfully, but these errors were encountered: