Storing an integer in an interface requires an allocation. Storing an
empty struct does not. This matches the pattern used for peer.NewContext
and metadata.NewContext.
This will assert at build time that the generated code is compatible
with the grpc package that it is linked to. A future change in the
grpc plugin for protoc-gen-go will generate a line like
const _ = grpc.SupportPackageIsVersion1
This constant will be renamed in the future when incompatible changes
are made that require synchronised updates to grpc and protoc-gen-go.
This simplifies the code that's used for wiring up the http.Handler-based
transport for testing. It's not used outside of tests.
http2.Server.ServeConn was added somewhat recently for other reasons and
I just realized it would simplify this code as well.
It's too noisy and not worth it. I don't like encouraging the code
coverage game, wherein people write bad tests to get points.
It's annoying to get a red X in the PR status when coverage dropped
by 1 line or 0.4%.
Good code review should be sufficient to verify we have both tests
and good tests.
The Framer now has support for merging HEADERS+CONTINUATION frames.
This remove the frame merging & hpack state machine from grpc.
In addition to being more compliant with the spec, this also means
gRPC enforces the header list size, removing a DoS vector.
Change-Id: Id46a6a1e741e62a859c3e3fb9f0cc36febf1d836
Move the test-only methods to a new internal package so as to not
pollute the godoc, and to prevent people from using them. (Packages
named internal or under internal are private, and enforced by the go
tool)
The http.Handler-based transport body reader was returning error types
not understood by the recvMsg parser. See #557 for some background and
examples.
Fix the http.Handler transport and add tests. I copied in a subset of
the http2 package's serverTest type, adapted slightly to work with
grpc. In the process of adding tests, I discovered that
ErrUnexpectedEOF was also not handled by the regular server
transport. Document the rules and fix that crash as well.
Unrelated stuff in this CL:
* make tests listen on localhost:0 instead of :0, to avoid Mac firewall
pop-up dialogs.
* rename parser.s field to parser.r, to be more idiomatic that it's an
io.Reader and not anything fancier. (it's not acting like type
stream, even if that's the typical concrete type)
* move 5 byte temp buffer into parser, rather than allocating it for
each new message. (drop in the bucket improvement in garbage; more
to do later)
* rename http2RSTErrConvTab to http2ErrConvTab, per Qi's earlier
CL. Also add the HTTP/1.1-required error mapping for completeness,
not that it should ever arise with gRPC, also per Qi's earlier CL
referenced in #557.
This removes serverSetUp and clientSetUp. They had too many positional
parameters and weren't readable at the call sites.
With this change, it's now much more obvious how a test differs from
others just be looking at what is tinkered with after newTest.
Change-Id: I59bb06f8029af166002033f2c3f7b8f0b2d20940
Filter expected log output by default, unless a flag is provided, or a
test fails.
This makes it possible to see unexpected things. Having noisy tests
makes it too easy to miss actual problems.