-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Issue Description
Background
I am currently using cpp-httplib, an excellent open source project, to handle HTTP requests in my application. One notable observation is that recent versions of cpp-httplib reject HTTP requests with unsupported headers, such as Content-Length
, within the parts of multipart/form-data messages. According to RFC 7578, Section 4.8, these headers "MUST NOT be included and MUST be ignored." In my interpretation of RFC 7578, this means that the client SHOULD NOT include these headers, and the server MAY ignore them when present.
Recent Change
I noticed that cpp-httplib started rejecting unsupported headers in multipart/form-data requests since commit 0ff2e16d69a315990c7232be06a636dac3c467e5. However, I do not have information about the rationale or context behind this change.
Request
I kindly request that the cpp-httplib project maintainers consider implementing a feature that allows cpp-httplib to gracefully handle and ignore unsupported headers when processing multipart/form-data requests.
Rationale
-
RFC 7578 Conformance: Supporting this feature will help ensure that cpp-httplib adheres to RFC 7578's requirements by ignoring unsupported headers within the parts of multipart/form-data messages.
-
Improved Compatibility: This change will enhance compatibility with a wide range of clients and ensure that the project behaves consistently with the RFC standard.
-
Enhanced Error Handling: Ignoring unsupported headers rather than rejecting the entire request could improve error handling by allowing cpp-httplib to process the request data while logging any non-conforming headers for debugging or auditing purposes.
Suggested Implementation
A suggested implementation approach could be to introduce a configuration option or a flag that enables or disables the strict checking of headers in multipart/form-data requests. When enabled, cpp-httplib would continue to follow the current behavior, rejecting requests with unsupported headers. When disabled, cpp-httplib would gracefully ignore unsupported headers and process the request data accordingly.