Both in add_header and in format_header we should check whether \r\n are present in header name or value.
A way to handle it:
Store start of header value
Check data just written into buffer
Truncate buffer back and return error
Alternative would be just panicking, but I think error makes more sense here.
Another arguable thing is if we want to do this only in debug build. Probably we can do this in debug build only if we are going to panic. Otherwise, users expect error to be returned regardless of build settings.
Both in
add_header
and informat_header
we should check whether\r\n
are present in header name or value.A way to handle it:
Alternative would be just panicking, but I think error makes more sense here.
Another arguable thing is if we want to do this only in debug build. Probably we can do this in debug build only if we are going to panic. Otherwise, users expect error to be returned regardless of build settings.