swindon-rs / tk-http

Full featured HTTP and Websockets library for rust/tokio
Apache License 2.0
136 stars 10 forks source link

Check header validity #10

Closed tailhook closed 8 years ago

tailhook commented 8 years ago

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:

  1. Store start of header value
  2. Check data just written into buffer
  3. 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.