fix SCGI parse_headers: defer content-type body peek until body received

detect_content_type() peeked at m_buffer[m_body] to infer JSON vs XML
when no CONTENT_TYPE header was provided.  When the TCP header segment
arrives without any body bytes, m_body equals m_position and the peek
reads the null terminator padding byte — not the actual '{' or '[' —
causing JSON requests to be incorrectly classified as XML and fail.

Fix:
 - Remove the body peek from detect_content_type(); defer it to after
   the full body is confirmed present in event_read().
 - Add a m_content_type_set flag to distinguish header-provided type
   from auto-detected type.
This commit is contained in:
trim21
2026-05-10 15:44:10 +08:00
committed by Jari Sundell
parent 26a7e9f545
commit b0ef95592b
3 changed files with 107 additions and 9 deletions
+1
View File
@@ -67,6 +67,7 @@ private:
bool m_accepts_compression{};
bool m_trusted{true};
bool m_content_type_set{false};
};
}