Open hawkw opened 3 years ago
Yea, the premise seems reasonable. I think the more general question, that of what "kinds" to even expose programmatically (also mentioned in https://github.com/hyperium/hyper/pull/2504#issuecomment-843661471), is also worth answering. Maybe here, maybe in a separate issue. I don't know the answer.
In this case in particular, we want to be able to determine when a header value is too large, h2
considers this a "user error" and says that its "user errors" are "errors caused by a user of the library", but since linkerd is a proxy, the too-large header was recieved from a client, and we want to return a 4xx error code in that case.
In the general case, it's definitely worth some more thought about what an appropriate level of granularity is, though.
Currently, when the
h2
crate returns an error, that error is wrapped by Hyper witherror::Kind::Http2
. However, several ofh2
s errors have analogous semantics to Hyper's error kinds. For example,h2
will return a "user error: header too big" error when encountering a header that's too large, and this could (potentially) be mapped to Hyper'sKind::Parse(Parse::TooLarge)
. This would be nice since it would make it possible for users to handle specific error cases the same way regardless of whether they occurred on an HTTP/1 or HTTP/2 connection.I think implementing this might require changes in
h2
as well to expose more information aboutUserError
s --- currently, theUserError
type is private, andh2
only allows determining whether an error is a user error, and formatting it...