Closed jbr closed 4 years ago
It is important for surf Response and Request to have a similar interface to tide and the underlying http-types for the principle of least surprise. Currently, Index is an exception to this, which is what this issue represents
I think this is describing the use of Index for looking up headers in the response, e.g.
response["Content-Length"]
. Is that right?I think it might be preferable not to implement Index, since it encourages users to risk a panic based on untrusted data. For instance, if I write an HTTP client that tries to examine
response["Content-Length"]
, all the server has to do to crash my client is send a response without that header field.The safe way to use Index here would be for the user to check if the header exists first:
But by then it's just as easy to use
values
.