• Brad Fitzpatrick's avatar
    http2: make Transport work around mod_h2 bug · 28d1bd4f
    Brad Fitzpatrick authored
    The http2 server implementation in Apache (mod_http2, aka mod_h2) had
    a bug where it didn't reply to the initial SETTINGS frame until it had
    received a request. Apache 2.4.17 was the first Apache version to
    include mod_http2 and has the bug.
    
    The bug was fixed 20 days ago
    (https://github.com/apache/httpd/commit/de4e3031aeb9775d2ebb9c917ecb1117c12d05f8)
    for Apache 2.5.0 and included in the out-of-tree mod_h2 1.5.12
    (https://github.com/icing/mod_h2/releases/tag/v1.5.12) but most Apache
    sites are running older versions making them incompatible with Go's
    client. (At least Debian Stretch and Ubuntu Xenial, currently.)
    
    Chrome, curl, Firefox et al don't wait for the initial SETTINGS
    response & ACK before sending their first request, which is why
    mod_http2 didn't notice their bug for some time.
    
    This change makes Go's http2.Transport act like other common HTTP/2
    clients and not wait for the peer's SETTINGS frame & ACK before
    sending the first request.
    
    As a bonus, this reduces the latency for the first request on
    connections by one RTT.
    
    The reason we waited for the initial settings is purely
    historical. Andrew and I just wrote it that way when initially
    developing the client on video (https://www.youtube.com/watch?v=yG-UaBJXZ80)
    because we were working top-down through the protocol and didn't
    get back to optimizing the RTT away. It also seemed more compliant to
    wait for the peer's SETTINGS to know the frame size and such, but as
    as spec says, it's permitted for clients to not wait:
    
    http://httpwg.org/specs/rfc7540.html#rfc.section.3.5
    
    > To avoid unnecessary latency, clients are permitted to send
    > additional frames to the server immediately after sending the client
    > connection preface, without waiting to receive the server connection
    > preface. It is important to note, however, that the server
    > connection preface SETTINGS frame might include parameters that
    > necessarily alter how a client is expected to communicate with the
    > server. Upon receiving the SETTINGS frame, the client is expected to
    > honor any parameters established. In some configurations, it is
    > possible for the server to transmit SETTINGS before the client sends
    > additional frames, providing an opportunity to avoid this issue.
    
    So, don't wait.
    
    Fixes golang/go#16519
    
    Change-Id: I916827e49829f7f107a51838512816916fb553fc
    Reviewed-on: https://go-review.googlesource.com/25362Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    28d1bd4f
Name
Last commit
Last update
bpf Loading commit data...
context Loading commit data...
dict Loading commit data...
html Loading commit data...
http2 Loading commit data...
icmp Loading commit data...
idna Loading commit data...
internal Loading commit data...
ipv4 Loading commit data...
ipv6 Loading commit data...
lex/httplex Loading commit data...
netutil Loading commit data...
proxy Loading commit data...
publicsuffix Loading commit data...
route Loading commit data...
trace Loading commit data...
webdav Loading commit data...
websocket Loading commit data...
xsrftoken Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README Loading commit data...
codereview.cfg Loading commit data...