Commit Graph

32 Commits

Author SHA1 Message Date
Peter Mattis a1d076a617 Use a bufio.Reader for input.
This reduces the number of system calls for reading network data,
providing a nice speedup when there are concurrent RPCs.
2016-03-09 12:07:58 -05:00
Brad Fitzpatrick ac5c8d7972 transport: use http2.Framer's MetaHeadersFrame functionality
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
2016-02-25 23:44:45 +00:00
Brad Fitzpatrick 110fd99e30 Fix crashes where transports returned errors unhandled by the message parser.
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.
2016-02-24 15:09:17 -08:00
Brad Fitzpatrick 8aa7cbbc33 transport: don't crash if peer sends an empty header field name
The grpc-http2 transport doesn't validate hpack-decoded field names to be
valid http2 field names before checking their first byte. Had it verified
first and found that the empty string is illegal, this crash wouldn't happen,
but currently a malicious request can crash a gRPC server by sending an empty
hpack string.
2016-02-10 21:53:30 +00:00
iamqizhao e000b83ffb Improve an error message 2016-02-09 11:16:47 -08:00
iamqizhao da3bb0c9f7 Support compression 2016-01-22 18:21:41 -08:00
iamqizhao 6a026b9f10 recover the content-type check 2015-10-20 16:20:52 -07:00
David Symonds eb3bd654cd Switch from github.com/bradfitz/http2 to golang.org/x/net/http2.
The latter is now the official HTTP2 package for Go.
2015-09-24 18:12:31 +10:00
iamqizhao 21395fb393 bump gRPC-Go to beta 2015-09-14 13:27:27 -07:00
iamqizhao bcc6d1ba11 tentatively disable content-type check 2015-09-02 22:23:11 -07:00
iamqizhao ccfc0efd97 check content-type == application/grpc 2015-09-02 16:52:46 -07:00
iamqizhao 1f3aecfe8e remove some dead code 2015-08-26 14:03:38 -07:00
iamqizhao c0e23d7ef3 make the tests happy 2015-08-26 12:40:24 -07:00
iamqizhao 125950284c separate auth info from normal metadata 2015-08-26 11:30:43 -07:00
iamqizhao 97574c6499 make the test happy 2015-08-24 11:40:40 -07:00
yangzhouhan 676c10ae4d gofmt 2015-08-10 17:42:54 -07:00
yangzhouhan 484e2d96e5 change the metadata datastructure 2015-08-10 16:06:27 -07:00
iamqizhao 766bcab28b an error code revision 2015-07-29 18:28:41 -07:00
iamqizhao 7ee8af59ef rename var 2015-07-24 17:38:26 -07:00
iamqizhao a95e7d874d allow space-delimited application-provided user agent 2015-07-24 17:29:42 -07:00
iamqizhao 20034b3877 Invert User-Agent order so application-provided string comes first 2015-07-24 17:14:26 -07:00
iamqizhao 611d960757 support user-agent and allow users attach their own application user agent string 2015-07-24 11:19:08 -07:00
Peter Edge 7c025e8694 move log package references to grpclog 2015-05-09 11:43:59 +02:00
Peter Edge 101c1e1935 change log package references to grpc/log 2015-05-09 01:16:40 +02:00
iamqizhao b8cfe25c6e bug fix: processing header fields regardless in order to keep HPACK tables consistent 2015-04-14 18:50:32 -07:00
iamqizhao 4214baa3c1 gofmt 2015-03-31 16:46:41 -07:00
iamqizhao 902316edc6 io batching on writing path 2015-03-17 16:05:09 -07:00
iamqizhao 491fdc57f4 change grpc/transport to transport in error messages 2015-02-25 11:21:34 -08:00
iamqizhao ad3b2b5492 :authority is a pseudo-header 2015-02-19 13:25:27 -08:00
Matt T. Proud a720ae6f48 Make error conveyance more idiomatic.
This commit applies two bulk changes to the grpc error reporting
mechanisms:

(1.) Error strings for errors that originate within grpc are prefixed
    with the package name for better clarity for where they originate
    since they could percolate up in the users call chains to the
    originator.

(2.) Errors that are, in fact, singletons have been converted from
    fmt.Errorf to errors.New and assigned as package-level variables.
    This bodes particularly well for enabling API customers to elect to
    handle these errors upon receipt via equality comparison.  This had
    been previous impossible with the original API.

Supplementarily, ``gofmt -w -s=true`` has been run on the repository to
cleanup residual defects, and it has detected and repaired a few.

TEST=Manual go test ./...
2015-02-19 13:17:17 +01:00
David Symonds 416f68f4b3 Update import paths to use the new official location of the Go gRPC package. 2015-02-09 11:46:20 +11:00
David Symonds e71095e0ec Move source files up one level.
The top-level directory in this repository is going to be
the main "grpc" package.
2015-02-09 11:33:38 +11:00