http2: don't hang a stream if trailers values are not provided

Pre-declared trailers are written after a server's request handler
returns, in which case the trailer header frame is also responsible
for closing the stream. However, if the server handler does not
define a trailer header value before returning, the headers are empty
and no header frame is written. In this case, the stream would simply

This change fixes this by closing the stream if there are no header
values but endStream is true. Some other options to consider:

1. Reset the stream with an error; the user didn't define a trailer value
   as they said they would. From my brief reading of the http/2 RFC,
   this isn't actually required.
2. Send an explicitly empty header value.

Change-Id: I07e01250df60ac33fa6d34beb81ec2fa7e43c146
GitHub-Last-Rev: dfc532d7857822d507b218e4cc2511bf0b6dfcbd
GitHub-Pull-Request: golang/net#31
Run-TryBot: Brad Fitzpatrick <>
TryBot-Result: Gobot Gobot <>
Reviewed-by: Brad Fitzpatrick <>
2 files changed
tree: 62aa258baa7e4de4b5b62b55f23ee565a614e342
  1. .gitattributes
  2. .gitignore
  9. bpf/
  10. codereview.cfg
  11. context/
  12. dict/
  13. dns/
  14. go.mod
  15. go.sum
  16. html/
  17. http/
  18. http2/
  19. icmp/
  20. idna/
  21. internal/
  22. ipv4/
  23. ipv6/
  24. lif/
  25. nettest/
  26. netutil/
  27. proxy/
  28. publicsuffix/
  29. route/
  30. trace/
  31. webdav/
  32. websocket/
  33. xsrftoken/

Go Networking

This repository holds supplementary Go networking libraries.


The easiest way to install is to run go get -u You can also manually git clone the repository to $GOPATH/src/

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see The main issue tracker for the net repository is located at Prefix your issue with “x/net:” in the subject line, so it is easy to find.