1. 01 Feb, 2016 1 commit
    • Brad Fitzpatrick's avatar
      http2: add mechanism to send undeclared Trailers mid handler · d513e585
      Brad Fitzpatrick authored
      This adds a way for http.Handlers to set trailers after the header has
      already been flushed. This comment from the code explains:
      
      // promoteUndeclaredTrailers permits http.Handlers to set trailers
      // after the header has already been flushed. Because the Go
      // ResponseWriter interface has no way to set Trailers (only the
      // Header), and because we didn't want to expand the ResponseWriter
      // interface, and because nobody used trailers, and because RFC 2616
      // says you SHOULD (but not must) predeclare any trailers in the
      // header, the official ResponseWriter rules said trailers in Go must
      // be predeclared, and then we reuse the same ResponseWriter.Header()
      // map to mean both Headers and Trailers.  When it's time to write the
      // Trailers, we pick out the fields of Headers that were declared as
      // trailers. That worked for a while, until we found the first major
      // user of Trailers in the wild: gRPC (using them only over http2),
      // and gRPC libraries permit setting trailers mid-stream without
      // predeclarnig them. So: change of plans. We still permit the old
      // way, but we also permit this hack: if a Header() key begins with
      // "Trailer:", the suffix of that key is a Trailer. Because ':' is an
      // invalid token byte anyway, there is no ambiguity. (And it's already
      // filtered out) It's mildly hacky, but not terrible.
      
      The official pre-declaring way still works. Example from net/http docs:
      https://golang.org/pkg/net/http/#example_ResponseWriter_trailers
      And ResponseWriter docs explaining it:
      https://golang.org/pkg/net/http/#ResponseWriter
      
      I don't want to add a new interface-assertable upgrade type (like
      Hijacker or Flusher) for this because it's hurts composability and
      makes everybody in the ecocsystem implement those, and two optional
      interfaces is already bad enough. This is a weird enough feature
      (Trailers by itself is weird enough), that I don't feel like a third
      optional interface is worth it.
      
      This code also filters invalid header fields (updates golang/go#14048),
      since I had to update that code as part of this. But I want to later
      return an error back to the user if possible. Or log something.
      
      With this CL, all the grpc-go end2end tests pass with a new http2-based
      Server implementation:
      https://github.com/bradfitz/grpc-go/commit/a06f8f0593bfa8a0af72e57fb3916144f7b30121
      
      Change-Id: I80f863d05a1810bd6f302f34932ad9df0a6646a6
      Reviewed-on: https://go-review.googlesource.com/19131Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      d513e585
  2. 26 Jan, 2016 3 commits
  3. 21 Jan, 2016 1 commit
  4. 20 Jan, 2016 2 commits
  5. 19 Jan, 2016 2 commits
  6. 18 Jan, 2016 1 commit
  7. 16 Jan, 2016 1 commit
  8. 15 Jan, 2016 2 commits
  9. 13 Jan, 2016 5 commits
  10. 12 Jan, 2016 2 commits
  11. 11 Jan, 2016 1 commit
  12. 09 Jan, 2016 1 commit
  13. 08 Jan, 2016 1 commit
  14. 07 Jan, 2016 5 commits
    • Brad Fitzpatrick's avatar
      http2: clean up debugging, rename GODEBUG key · 415f1917
      Brad Fitzpatrick authored
      GODEBUG=h2debug=1 is now GODEBUG=http2debug=1, per golang/go#13611
      (comment https://github.com/golang/go/issues/13611#issuecomment-169534496)
      and there is a new debugging level h2debug=2 for logging all written frames
      as well, which was code I originally wrote for debugging the lego/ACME/Akamai
      issues in golang/go#13637 and letsencrypt/boulder#1279.
      
      This also moves the common vlogf calls inside if VerboseLogs blocks,
      to avoid allocations. I didn't do the rare ones.
      
      Example client output, fetching https://ip.appspot.com/:
      
      2016/01/07 23:24:52 http2: Transport failed to get client conn for ip.appspot.com:443: http2: no cached connection was available
      2016/01/07 23:24:52 http2: Transport creating client conn to 64.233.183.141:443
      2016/01/07 23:24:52 http2: Framer 0xc82028c420: wrote SETTINGS len=12, settings: ENABLE_PUSH=0, INITIAL_WINDOW_SIZE=4194304
      2016/01/07 23:24:52 http2: Framer 0xc82028c420: wrote WINDOW_UPDATE len=4 (conn) incr=1073741824
      2016/01/07 23:24:52 http2: Framer 0xc82028c420: wrote SETTINGS flags=ACK len=0
      2016/01/07 23:24:52 http2: Transport encoding header ":authority" = "ip.appspot.com"
      2016/01/07 23:24:52 http2: Transport encoding header ":method" = "GET"
      2016/01/07 23:24:52 http2: Transport encoding header ":path" = "/"
      2016/01/07 23:24:52 http2: Transport encoding header ":scheme" = "https"
      2016/01/07 23:24:52 http2: Transport encoding header "accept-encoding" = "gzip"
      2016/01/07 23:24:52 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
      2016/01/07 23:24:52 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
      2016/01/07 23:24:52 http2: Framer 0xc82028c420: wrote HEADERS flags=END_STREAM|END_HEADERS stream=1 len=35
      2016/01/07 23:24:52 http2: Transport received SETTINGS flags=ACK len=0
      2016/01/07 23:24:52 http2: Transport received HEADERS flags=END_HEADERS stream=1 len=123
      2016/01/07 23:24:52 http2: Transport decoded header field ":status" = "200"
      2016/01/07 23:24:52 http2: Transport decoded header field "content-type" = "text/plain;"
      2016/01/07 23:24:52 http2: Transport decoded header field "date" = "Thu, 07 Jan 2016 23:24:52 GMT"
      2016/01/07 23:24:52 http2: Transport decoded header field "server" = "Google Frontend"
      2016/01/07 23:24:52 http2: Transport decoded header field "content-length" = "14"
      2016/01/07 23:24:52 http2: Transport decoded header field "alternate-protocol" = "443:quic,p=1"
      2016/01/07 23:24:52 http2: Transport decoded header field "alt-svc" = "quic=\":443\"; ma=604800; v=\"30,29,28,27,26,25\""
      2016/01/07 23:24:52 http2: Transport received DATA flags=END_STREAM stream=1 len=14 data="146.148.92.232"
      2016/01/07 23:24:52 http2: Transport received PING len=8 ping="\x00\x00\x00\x00\x00\x00\x00\x00"
      2016/01/07 23:24:52 http2: Framer 0xc82028c420: wrote PING flags=ACK len=8 ping="\x00\x00\x00\x00\x00\x00\x00\x00"
      
      Example server output, with a client fetching / and getting a 404:
      
      2016/01/07 23:25:45 http2: server connection from 72.14.229.81:58273 on 0xc820066100
      2016/01/07 23:25:45 http2: server: error reading preface from client 72.14.229.81:58273: EOF
      2016/01/07 23:25:45 http2: Framer 0xc820228210: wrote SETTINGS len=18, settings: MAX_FRAME_SIZE=1048576, MAX_CONCURRENT_STREAMS=250, MAX_HEADER_LIST_SIZE=1048896
      2016/01/07 23:25:45 http2: server connection from 72.14.229.81:6801 on 0xc820066100
      2016/01/07 23:25:45 http2: Framer 0xc8202e8370: wrote SETTINGS len=18, settings: MAX_FRAME_SIZE=1048576, MAX_CONCURRENT_STREAMS=250, MAX_HEADER_LIST_SIZE=1048896
      2016/01/07 23:25:45 http2: server: client 72.14.229.81:6801 said hello
      2016/01/07 23:25:45 http2: server read frame SETTINGS len=12, settings: MAX_CONCURRENT_STREAMS=1000, INITIAL_WINDOW_SIZE=6291456
      2016/01/07 23:25:45 http2: server processing setting [MAX_CONCURRENT_STREAMS = 1000]
      2016/01/07 23:25:45 http2: server processing setting [INITIAL_WINDOW_SIZE = 6291456]
      2016/01/07 23:25:45 http2: Framer 0xc8202e8370: wrote SETTINGS flags=ACK len=0
      2016/01/07 23:25:45 http2: server read frame WINDOW_UPDATE len=4 (conn) incr=15663105
      2016/01/07 23:25:45 http2: server read frame HEADERS flags=END_STREAM|END_HEADERS|PRIORITY stream=1 len=238
      2016/01/07 23:25:45 http2: server decoded header field ":method" = "GET"
      2016/01/07 23:25:45 http2: server decoded header field ":authority" = "(redacted):4430"
      2016/01/07 23:25:45 http2: server decoded header field ":scheme" = "https"
      2016/01/07 23:25:45 http2: server decoded header field ":path" = "/"
      2016/01/07 23:25:45 http2: server decoded header field "cache-control" = "max-age=0"
      2016/01/07 23:25:45 http2: server decoded header field "accept" = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
      2016/01/07 23:25:45 http2: server decoded header field "upgrade-insecure-requests" = "1"
      2016/01/07 23:25:45 http2: server decoded header field "user-agent" = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537."
      2016/01/07 23:25:45 http2: server decoded header field "accept-encoding" = "gzip, deflate, sdch"
      2016/01/07 23:25:45 http2: server decoded header field "accept-language" = "en-US,en;q=0.8"
      2016/01/07 23:25:45 http2: server encoding header ":status" = "404"
      2016/01/07 23:25:45 http2: server encoding header "content-type" = "text/plain; charset=utf-8"
      2016/01/07 23:25:45 http2: server encoding header "x-content-type-options" = "nosniff"
      2016/01/07 23:25:45 http2: server encoding header "content-length" = "19"
      2016/01/07 23:25:45 http2: server encoding header "date" = "Thu, 07 Jan 2016 23:25:45 GMT"
      2016/01/07 23:25:45 http2: Framer 0xc8202e8370: wrote HEADERS flags=END_HEADERS stream=1 len=73
      2016/01/07 23:25:45 http2: Framer 0xc8202e8370: wrote DATA flags=END_STREAM stream=1 len=19 data="404 page not found\n"
      2016/01/07 23:25:45 http2: server read frame SETTINGS flags=ACK len=0
      
      Change-Id: Ifb3fe4e588ff54abd8bc3facbb419c3c3809bcba
      Reviewed-on: https://go-review.googlesource.com/18372Reviewed-by: 's avatarBlake Mizerany <blake.mizerany@gmail.com>
      Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
      415f1917
    • Brad Fitzpatrick's avatar
      http2: mix cleanups, TODOs, new tests, enforce header list size in Transport · f530c4eb
      Brad Fitzpatrick authored
      Just re-reading the code and polishing things up.
      
      Nothing major. Enforcing the max header list size in the Transport and
      letting it be configurable (not exposed in Go 1.6, only via x/net) is
      the most notable. Mostly just tests.
      
      Change-Id: Iacbad5a0b1ba0df9296b1aecfbc8b9b83323d435
      Reviewed-on: https://go-review.googlesource.com/18367Reviewed-by: 's avatarBlake Mizerany <blake.mizerany@gmail.com>
      f530c4eb
    • Brad Fitzpatrick's avatar
      http2: make Transport ignore 100-continue responses, add comprehensive tests · 520af5de
      Brad Fitzpatrick authored
      This makes the Transport ignore 100-continue responses from servers,
      rather than get confused by them. This is good enough for
      golang/go#13659. I filed golang/go#13851 to do better later, but
      that's less important.
      
      This CL also adds comprehensive tests for the 36 different ways that
      frames can be arranged from servers when reading a response. That
      exposed some bugs (now fixed), and even affected the http2 API: I'd
      added a END_STREAM accessor on CONTINUATION frames, but it's not even
      valid there.
      
      I also renamed some confusing variables which sounded too similar.
      
      Updates golang/go#13659
      Updates golang/go#13851
      
      Change-Id: I58868a27258981267f1b2043f711f50a42ec744a
      Reviewed-on: https://go-review.googlesource.com/18370Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
      520af5de
    • Mikio Hara's avatar
      http2: fix nits found by vet · 1d7a0b21
      Mikio Hara authored
      Change-Id: Ic4a3cc83d0f76a6a0d5e90b256761877151ab1e9
      Reviewed-on: https://go-review.googlesource.com/18279Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      1d7a0b21
    • Brad Fitzpatrick's avatar
      http2: fix Transport cancelation problems · d1ba2606
      Brad Fitzpatrick authored
      The Transport code wasn't always sending a RST_STREAM to the server
      in a few cases, and was also forgetting to flush its buffer.
      
      I believe each part of this change was part of making golang/go#13556
      not flaky. No additional tests at the moment;
      TestTransportAndServerSharedBodyRace_h2 is pretty comprehensive as-is,
      at least for an integration test. I should probably add some
      finer-grained tests in the future.
      
      Updates golang/go#13556
      
      Change-Id: Ie824202b20ba6ee85b20edeeee86ec977e6daeb2
      Reviewed-on: https://go-review.googlesource.com/18288Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
      d1ba2606
  15. 06 Jan, 2016 2 commits
  16. 05 Jan, 2016 1 commit
  17. 04 Jan, 2016 1 commit
  18. 29 Dec, 2015 1 commit
  19. 24 Dec, 2015 2 commits
  20. 21 Dec, 2015 1 commit
  21. 19 Dec, 2015 1 commit
  22. 17 Dec, 2015 3 commits