ires 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -45
- data/ext/Gopkg.lock +31 -1
- data/ext/ires/image.go +227 -0
- data/ext/ires/ires.go +47 -59
- data/ext/ires/uri.go +143 -0
- data/ext/main.go +18 -9
- data/ext/vendor/github.com/PuerkitoBio/purell/LICENSE +12 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/README.md +187 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/bench_test.go +57 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/benchmarks/v0.1.0 +9 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/example_test.go +35 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/purell.go +379 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/purell_test.go +768 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/urlnorm_test.go +53 -0
- data/ext/vendor/github.com/PuerkitoBio/urlesc/LICENSE +27 -0
- data/ext/vendor/github.com/PuerkitoBio/urlesc/README.md +16 -0
- data/ext/vendor/github.com/PuerkitoBio/urlesc/urlesc.go +180 -0
- data/ext/vendor/github.com/PuerkitoBio/urlesc/urlesc_test.go +641 -0
- data/ext/vendor/github.com/{satori/go.uuid → goware/urlx}/LICENSE +3 -1
- data/ext/vendor/github.com/goware/urlx/README.md +172 -0
- data/ext/vendor/github.com/goware/urlx/urlx.go +196 -0
- data/ext/vendor/github.com/goware/urlx/urlx_test.go +232 -0
- data/ext/vendor/golang.org/x/net/AUTHORS +3 -0
- data/ext/vendor/golang.org/x/net/CONTRIBUTING.md +31 -0
- data/ext/vendor/golang.org/x/net/CONTRIBUTORS +3 -0
- data/ext/vendor/golang.org/x/net/LICENSE +27 -0
- data/ext/vendor/golang.org/x/net/PATENTS +22 -0
- data/ext/vendor/golang.org/x/net/README.md +16 -0
- data/ext/vendor/golang.org/x/net/bpf/asm.go +41 -0
- data/ext/vendor/golang.org/x/net/bpf/constants.go +218 -0
- data/ext/vendor/golang.org/x/net/bpf/doc.go +82 -0
- data/ext/vendor/golang.org/x/net/bpf/instructions.go +704 -0
- data/ext/vendor/golang.org/x/net/bpf/instructions_test.go +525 -0
- data/ext/vendor/golang.org/x/net/bpf/setter.go +10 -0
- data/ext/vendor/golang.org/x/net/bpf/testdata/all_instructions.bpf +1 -0
- data/ext/vendor/golang.org/x/net/bpf/testdata/all_instructions.txt +79 -0
- data/ext/vendor/golang.org/x/net/bpf/vm.go +140 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_aluop_test.go +512 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_bpf_test.go +192 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_extension_test.go +49 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_instructions.go +174 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_jump_test.go +380 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_load_test.go +246 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_ret_test.go +115 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_scratch_test.go +247 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_test.go +144 -0
- data/ext/vendor/golang.org/x/net/codereview.cfg +1 -0
- data/ext/vendor/golang.org/x/net/context/context.go +54 -0
- data/ext/vendor/golang.org/x/net/context/context_test.go +583 -0
- data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go +74 -0
- data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_17_test.go +29 -0
- data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go +147 -0
- data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17_test.go +79 -0
- data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_test.go +105 -0
- data/ext/vendor/golang.org/x/net/context/go17.go +72 -0
- data/ext/vendor/golang.org/x/net/context/go19.go +20 -0
- data/ext/vendor/golang.org/x/net/context/pre_go17.go +300 -0
- data/ext/vendor/golang.org/x/net/context/pre_go19.go +109 -0
- data/ext/vendor/golang.org/x/net/context/withtimeout_test.go +31 -0
- data/ext/vendor/golang.org/x/net/dict/dict.go +210 -0
- data/ext/vendor/golang.org/x/net/dns/dnsmessage/example_test.go +132 -0
- data/ext/vendor/golang.org/x/net/dns/dnsmessage/message.go +1997 -0
- data/ext/vendor/golang.org/x/net/dns/dnsmessage/message_test.go +1116 -0
- data/ext/vendor/golang.org/x/net/html/atom/atom.go +78 -0
- data/ext/vendor/golang.org/x/net/html/atom/atom_test.go +109 -0
- data/ext/vendor/golang.org/x/net/html/atom/gen.go +709 -0
- data/ext/vendor/golang.org/x/net/html/atom/table.go +777 -0
- data/ext/vendor/golang.org/x/net/html/atom/table_test.go +373 -0
- data/ext/vendor/golang.org/x/net/html/charset/charset.go +257 -0
- data/ext/vendor/golang.org/x/net/html/charset/charset_test.go +237 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-charset.html +48 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-UTF-8-BOM.html +48 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-charset.html +49 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-content.html +49 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/No-encoding-declaration.html +47 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/README +9 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-16BE-BOM.html +0 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-16LE-BOM.html +0 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-charset.html +49 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-content.html +48 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/meta-charset-attribute.html +48 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/meta-content-attribute.html +48 -0
- data/ext/vendor/golang.org/x/net/html/const.go +104 -0
- data/ext/vendor/golang.org/x/net/html/doc.go +106 -0
- data/ext/vendor/golang.org/x/net/html/doctype.go +156 -0
- data/ext/vendor/golang.org/x/net/html/entity.go +2253 -0
- data/ext/vendor/golang.org/x/net/html/entity_test.go +29 -0
- data/ext/vendor/golang.org/x/net/html/escape.go +258 -0
- data/ext/vendor/golang.org/x/net/html/escape_test.go +97 -0
- data/ext/vendor/golang.org/x/net/html/example_test.go +40 -0
- data/ext/vendor/golang.org/x/net/html/foreign.go +226 -0
- data/ext/vendor/golang.org/x/net/html/node.go +193 -0
- data/ext/vendor/golang.org/x/net/html/node_test.go +146 -0
- data/ext/vendor/golang.org/x/net/html/parse.go +2094 -0
- data/ext/vendor/golang.org/x/net/html/parse_test.go +388 -0
- data/ext/vendor/golang.org/x/net/html/render.go +271 -0
- data/ext/vendor/golang.org/x/net/html/render_test.go +156 -0
- data/ext/vendor/golang.org/x/net/html/testdata/go1.html +2237 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/README +28 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/adoption01.dat +194 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/adoption02.dat +31 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/comments01.dat +135 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/doctype01.dat +370 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/entities01.dat +603 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/entities02.dat +249 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/html5test-com.dat +246 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/inbody01.dat +43 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/isindex.dat +40 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/pending-spec-changes-plain-text-unsafe.dat +0 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/pending-spec-changes.dat +52 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/plain-text-unsafe.dat +0 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/scriptdata01.dat +308 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/scripted/adoption01.dat +15 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/scripted/webkit01.dat +28 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tables01.dat +212 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests1.dat +1952 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests10.dat +799 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests11.dat +482 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests12.dat +62 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests14.dat +74 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests15.dat +208 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests16.dat +2299 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests17.dat +153 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests18.dat +269 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests19.dat +1237 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests2.dat +763 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests20.dat +455 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests21.dat +221 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests22.dat +157 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests23.dat +155 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests24.dat +79 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests25.dat +219 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests26.dat +313 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests3.dat +305 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests4.dat +59 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests5.dat +191 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests6.dat +663 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests7.dat +390 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests8.dat +148 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests9.dat +457 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests_innerHTML_1.dat +741 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tricky01.dat +261 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/webkit01.dat +610 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/webkit02.dat +159 -0
- data/ext/vendor/golang.org/x/net/html/token.go +1219 -0
- data/ext/vendor/golang.org/x/net/html/token_test.go +748 -0
- data/ext/vendor/golang.org/x/net/http2/Dockerfile +51 -0
- data/ext/vendor/golang.org/x/net/http2/Makefile +3 -0
- data/ext/vendor/golang.org/x/net/http2/README +20 -0
- data/ext/vendor/golang.org/x/net/http2/ciphers.go +641 -0
- data/ext/vendor/golang.org/x/net/http2/ciphers_test.go +309 -0
- data/ext/vendor/golang.org/x/net/http2/client_conn_pool.go +256 -0
- data/ext/vendor/golang.org/x/net/http2/configure_transport.go +80 -0
- data/ext/vendor/golang.org/x/net/http2/databuffer.go +146 -0
- data/ext/vendor/golang.org/x/net/http2/databuffer_test.go +157 -0
- data/ext/vendor/golang.org/x/net/http2/errors.go +133 -0
- data/ext/vendor/golang.org/x/net/http2/errors_test.go +24 -0
- data/ext/vendor/golang.org/x/net/http2/flow.go +50 -0
- data/ext/vendor/golang.org/x/net/http2/flow_test.go +53 -0
- data/ext/vendor/golang.org/x/net/http2/frame.go +1579 -0
- data/ext/vendor/golang.org/x/net/http2/frame_test.go +1191 -0
- data/ext/vendor/golang.org/x/net/http2/go16.go +16 -0
- data/ext/vendor/golang.org/x/net/http2/go17.go +106 -0
- data/ext/vendor/golang.org/x/net/http2/go17_not18.go +36 -0
- data/ext/vendor/golang.org/x/net/http2/go18.go +56 -0
- data/ext/vendor/golang.org/x/net/http2/go18_test.go +79 -0
- data/ext/vendor/golang.org/x/net/http2/go19.go +16 -0
- data/ext/vendor/golang.org/x/net/http2/go19_test.go +60 -0
- data/ext/vendor/golang.org/x/net/http2/gotrack.go +170 -0
- data/ext/vendor/golang.org/x/net/http2/gotrack_test.go +33 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/Makefile +8 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/README +16 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/h2demo.go +538 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/launch.go +302 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/rootCA.key +27 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/rootCA.pem +26 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/rootCA.srl +1 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/server.crt +20 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/server.key +27 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/tmpl.go +1991 -0
- data/ext/vendor/golang.org/x/net/http2/h2i/README.md +97 -0
- data/ext/vendor/golang.org/x/net/http2/h2i/h2i.go +522 -0
- data/ext/vendor/golang.org/x/net/http2/headermap.go +78 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/encode.go +240 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/encode_test.go +386 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/hpack.go +490 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/hpack_test.go +722 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/huffman.go +212 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/tables.go +479 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/tables_test.go +214 -0
- data/ext/vendor/golang.org/x/net/http2/http2.go +391 -0
- data/ext/vendor/golang.org/x/net/http2/http2_test.go +199 -0
- data/ext/vendor/golang.org/x/net/http2/not_go16.go +21 -0
- data/ext/vendor/golang.org/x/net/http2/not_go17.go +87 -0
- data/ext/vendor/golang.org/x/net/http2/not_go18.go +29 -0
- data/ext/vendor/golang.org/x/net/http2/not_go19.go +16 -0
- data/ext/vendor/golang.org/x/net/http2/pipe.go +163 -0
- data/ext/vendor/golang.org/x/net/http2/pipe_test.go +130 -0
- data/ext/vendor/golang.org/x/net/http2/server.go +2857 -0
- data/ext/vendor/golang.org/x/net/http2/server_push_test.go +521 -0
- data/ext/vendor/golang.org/x/net/http2/server_test.go +3721 -0
- data/ext/vendor/golang.org/x/net/http2/testdata/draft-ietf-httpbis-http2.xml +5021 -0
- data/ext/vendor/golang.org/x/net/http2/transport.go +2285 -0
- data/ext/vendor/golang.org/x/net/http2/transport_test.go +3714 -0
- data/ext/vendor/golang.org/x/net/http2/write.go +370 -0
- data/ext/vendor/golang.org/x/net/http2/writesched.go +242 -0
- data/ext/vendor/golang.org/x/net/http2/writesched_priority.go +452 -0
- data/ext/vendor/golang.org/x/net/http2/writesched_priority_test.go +541 -0
- data/ext/vendor/golang.org/x/net/http2/writesched_random.go +72 -0
- data/ext/vendor/golang.org/x/net/http2/writesched_random_test.go +44 -0
- data/ext/vendor/golang.org/x/net/http2/writesched_test.go +125 -0
- data/ext/vendor/golang.org/x/net/http2/z_spec_test.go +356 -0
- data/ext/vendor/golang.org/x/net/icmp/dstunreach.go +41 -0
- data/ext/vendor/golang.org/x/net/icmp/echo.go +45 -0
- data/ext/vendor/golang.org/x/net/icmp/endpoint.go +113 -0
- data/ext/vendor/golang.org/x/net/icmp/example_test.go +63 -0
- data/ext/vendor/golang.org/x/net/icmp/extension.go +89 -0
- data/ext/vendor/golang.org/x/net/icmp/extension_test.go +259 -0
- data/ext/vendor/golang.org/x/net/icmp/helper_posix.go +75 -0
- data/ext/vendor/golang.org/x/net/icmp/interface.go +236 -0
- data/ext/vendor/golang.org/x/net/icmp/ipv4.go +61 -0
- data/ext/vendor/golang.org/x/net/icmp/ipv4_test.go +83 -0
- data/ext/vendor/golang.org/x/net/icmp/ipv6.go +23 -0
- data/ext/vendor/golang.org/x/net/icmp/listen_posix.go +100 -0
- data/ext/vendor/golang.org/x/net/icmp/listen_stub.go +33 -0
- data/ext/vendor/golang.org/x/net/icmp/message.go +152 -0
- data/ext/vendor/golang.org/x/net/icmp/message_test.go +134 -0
- data/ext/vendor/golang.org/x/net/icmp/messagebody.go +41 -0
- data/ext/vendor/golang.org/x/net/icmp/mpls.go +77 -0
- data/ext/vendor/golang.org/x/net/icmp/multipart.go +109 -0
- data/ext/vendor/golang.org/x/net/icmp/multipart_test.go +442 -0
- data/ext/vendor/golang.org/x/net/icmp/packettoobig.go +43 -0
- data/ext/vendor/golang.org/x/net/icmp/paramprob.go +63 -0
- data/ext/vendor/golang.org/x/net/icmp/ping_test.go +200 -0
- data/ext/vendor/golang.org/x/net/icmp/sys_freebsd.go +11 -0
- data/ext/vendor/golang.org/x/net/icmp/timeexceeded.go +39 -0
- data/ext/vendor/golang.org/x/net/idna/example_test.go +70 -0
- data/ext/vendor/golang.org/x/net/idna/idna.go +680 -0
- data/ext/vendor/golang.org/x/net/idna/idna_test.go +108 -0
- data/ext/vendor/golang.org/x/net/idna/punycode.go +203 -0
- data/ext/vendor/golang.org/x/net/idna/punycode_test.go +198 -0
- data/ext/vendor/golang.org/x/net/idna/tables.go +4477 -0
- data/ext/vendor/golang.org/x/net/idna/trie.go +72 -0
- data/ext/vendor/golang.org/x/net/idna/trieval.go +114 -0
- data/ext/vendor/golang.org/x/net/internal/iana/const.go +180 -0
- data/ext/vendor/golang.org/x/net/internal/iana/gen.go +293 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/helper_bsd.go +53 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/helper_nobsd.go +15 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/helper_posix.go +31 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/helper_stub.go +32 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/helper_unix.go +29 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/helper_windows.go +42 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/interface.go +94 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/rlimit.go +11 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/stack.go +147 -0
- data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr.go +11 -0
- data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go +13 -0
- data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go +14 -0
- data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go +14 -0
- data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go +14 -0
- data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go +17 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_darwin.go +44 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_dragonfly.go +44 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_freebsd.go +44 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_linux.go +49 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_netbsd.go +47 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_openbsd.go +44 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_solaris.go +44 -0
- data/ext/vendor/golang.org/x/net/internal/socket/error_unix.go +31 -0
- data/ext/vendor/golang.org/x/net/internal/socket/error_windows.go +26 -0
- data/ext/vendor/golang.org/x/net/internal/socket/iovec_32bit.go +19 -0
- data/ext/vendor/golang.org/x/net/internal/socket/iovec_64bit.go +19 -0
- data/ext/vendor/golang.org/x/net/internal/socket/iovec_solaris_64bit.go +19 -0
- data/ext/vendor/golang.org/x/net/internal/socket/iovec_stub.go +11 -0
- data/ext/vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go +21 -0
- data/ext/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go +42 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_bsd.go +39 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go +16 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_linux.go +36 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_linux_32bit.go +24 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go +24 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_openbsd.go +14 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_solaris_64bit.go +36 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_stub.go +14 -0
- data/ext/vendor/golang.org/x/net/internal/socket/rawconn.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go +74 -0
- data/ext/vendor/golang.org/x/net/internal/socket/rawconn_msg.go +77 -0
- data/ext/vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go +18 -0
- data/ext/vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go +18 -0
- data/ext/vendor/golang.org/x/net/internal/socket/rawconn_stub.go +25 -0
- data/ext/vendor/golang.org/x/net/internal/socket/reflect.go +62 -0
- data/ext/vendor/golang.org/x/net/internal/socket/socket.go +285 -0
- data/ext/vendor/golang.org/x/net/internal/socket/socket_go1_9_test.go +259 -0
- data/ext/vendor/golang.org/x/net/internal/socket/socket_test.go +46 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys.go +33 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_bsd.go +17 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_bsdvar.go +14 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_darwin.go +7 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_dragonfly.go +7 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux.go +27 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_386.go +55 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_386.s +11 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_amd64.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_arm.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_arm64.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mips.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mips64.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mips64le.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mipsle.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64le.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.go +55 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.s +11 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_netbsd.go +25 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_posix.go +168 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_solaris.go +71 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_solaris_amd64.s +11 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_stub.go +64 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_unix.go +33 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_windows.go +70 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_darwin_386.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_darwin_amd64.go +61 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_darwin_arm.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_dragonfly_amd64.go +61 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_freebsd_386.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_freebsd_amd64.go +61 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_freebsd_arm.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_386.go +63 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_amd64.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_arm.go +63 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_arm64.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mips.go +63 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64le.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mipsle.go +63 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64le.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_s390x.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_netbsd_386.go +65 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_netbsd_amd64.go +68 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_netbsd_arm.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_openbsd_386.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_openbsd_amd64.go +61 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_openbsd_arm.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_solaris_amd64.go +60 -0
- data/ext/vendor/golang.org/x/net/internal/timeseries/timeseries.go +525 -0
- data/ext/vendor/golang.org/x/net/internal/timeseries/timeseries_test.go +170 -0
- data/ext/vendor/golang.org/x/net/ipv4/batch.go +191 -0
- data/ext/vendor/golang.org/x/net/ipv4/bpf_test.go +93 -0
- data/ext/vendor/golang.org/x/net/ipv4/control.go +144 -0
- data/ext/vendor/golang.org/x/net/ipv4/control_bsd.go +40 -0
- data/ext/vendor/golang.org/x/net/ipv4/control_pktinfo.go +39 -0
- data/ext/vendor/golang.org/x/net/ipv4/control_stub.go +13 -0
- data/ext/vendor/golang.org/x/net/ipv4/control_test.go +21 -0
- data/ext/vendor/golang.org/x/net/ipv4/control_unix.go +73 -0
- data/ext/vendor/golang.org/x/net/ipv4/control_windows.go +16 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_darwin.go +77 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_dragonfly.go +38 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_freebsd.go +75 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_linux.go +122 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_netbsd.go +37 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_openbsd.go +37 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_solaris.go +84 -0
- data/ext/vendor/golang.org/x/net/ipv4/dgramopt.go +265 -0
- data/ext/vendor/golang.org/x/net/ipv4/doc.go +244 -0
- data/ext/vendor/golang.org/x/net/ipv4/endpoint.go +187 -0
- data/ext/vendor/golang.org/x/net/ipv4/example_test.go +224 -0
- data/ext/vendor/golang.org/x/net/ipv4/gen.go +199 -0
- data/ext/vendor/golang.org/x/net/ipv4/genericopt.go +57 -0
- data/ext/vendor/golang.org/x/net/ipv4/header.go +159 -0
- data/ext/vendor/golang.org/x/net/ipv4/header_test.go +228 -0
- data/ext/vendor/golang.org/x/net/ipv4/helper.go +63 -0
- data/ext/vendor/golang.org/x/net/ipv4/iana.go +34 -0
- data/ext/vendor/golang.org/x/net/ipv4/icmp.go +57 -0
- data/ext/vendor/golang.org/x/net/ipv4/icmp_linux.go +25 -0
- data/ext/vendor/golang.org/x/net/ipv4/icmp_stub.go +25 -0
- data/ext/vendor/golang.org/x/net/ipv4/icmp_test.go +95 -0
- data/ext/vendor/golang.org/x/net/ipv4/multicast_test.go +334 -0
- data/ext/vendor/golang.org/x/net/ipv4/multicastlistener_test.go +265 -0
- data/ext/vendor/golang.org/x/net/ipv4/multicastsockopt_test.go +195 -0
- data/ext/vendor/golang.org/x/net/ipv4/packet.go +69 -0
- data/ext/vendor/golang.org/x/net/ipv4/packet_go1_8.go +56 -0
- data/ext/vendor/golang.org/x/net/ipv4/packet_go1_9.go +67 -0
- data/ext/vendor/golang.org/x/net/ipv4/payload.go +23 -0
- data/ext/vendor/golang.org/x/net/ipv4/payload_cmsg.go +36 -0
- data/ext/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_8.go +59 -0
- data/ext/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_9.go +67 -0
- data/ext/vendor/golang.org/x/net/ipv4/payload_nocmsg.go +42 -0
- data/ext/vendor/golang.org/x/net/ipv4/readwrite_go1_8_test.go +248 -0
- data/ext/vendor/golang.org/x/net/ipv4/readwrite_go1_9_test.go +388 -0
- data/ext/vendor/golang.org/x/net/ipv4/readwrite_test.go +140 -0
- data/ext/vendor/golang.org/x/net/ipv4/sockopt.go +44 -0
- data/ext/vendor/golang.org/x/net/ipv4/sockopt_posix.go +71 -0
- data/ext/vendor/golang.org/x/net/ipv4/sockopt_stub.go +42 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_asmreq.go +119 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_asmreq_stub.go +25 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_asmreqn.go +42 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_asmreqn_stub.go +21 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_bpf.go +23 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_bpf_stub.go +16 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_bsd.go +37 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_darwin.go +93 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_dragonfly.go +35 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_freebsd.go +76 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_linux.go +59 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_solaris.go +57 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_ssmreq.go +54 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_ssmreq_stub.go +21 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_stub.go +13 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_windows.go +67 -0
- data/ext/vendor/golang.org/x/net/ipv4/unicast_test.go +247 -0
- data/ext/vendor/golang.org/x/net/ipv4/unicastsockopt_test.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_darwin.go +99 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go +31 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go +93 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go +95 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go +95 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_386.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_netbsd.go +30 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_openbsd.go +30 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_solaris.go +100 -0
- data/ext/vendor/golang.org/x/net/ipv6/batch.go +119 -0
- data/ext/vendor/golang.org/x/net/ipv6/bpf_test.go +96 -0
- data/ext/vendor/golang.org/x/net/ipv6/control.go +187 -0
- data/ext/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go +48 -0
- data/ext/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go +94 -0
- data/ext/vendor/golang.org/x/net/ipv6/control_stub.go +13 -0
- data/ext/vendor/golang.org/x/net/ipv6/control_test.go +21 -0
- data/ext/vendor/golang.org/x/net/ipv6/control_unix.go +55 -0
- data/ext/vendor/golang.org/x/net/ipv6/control_windows.go +16 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_darwin.go +112 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_dragonfly.go +84 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_freebsd.go +105 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_linux.go +147 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_netbsd.go +80 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_openbsd.go +89 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_solaris.go +114 -0
- data/ext/vendor/golang.org/x/net/ipv6/dgramopt.go +302 -0
- data/ext/vendor/golang.org/x/net/ipv6/doc.go +243 -0
- data/ext/vendor/golang.org/x/net/ipv6/endpoint.go +128 -0
- data/ext/vendor/golang.org/x/net/ipv6/example_test.go +216 -0
- data/ext/vendor/golang.org/x/net/ipv6/gen.go +199 -0
- data/ext/vendor/golang.org/x/net/ipv6/genericopt.go +58 -0
- data/ext/vendor/golang.org/x/net/ipv6/header.go +55 -0
- data/ext/vendor/golang.org/x/net/ipv6/header_test.go +55 -0
- data/ext/vendor/golang.org/x/net/ipv6/helper.go +57 -0
- data/ext/vendor/golang.org/x/net/ipv6/iana.go +82 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp.go +60 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp_bsd.go +29 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp_linux.go +27 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp_solaris.go +27 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp_stub.go +23 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp_test.go +96 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp_windows.go +22 -0
- data/ext/vendor/golang.org/x/net/ipv6/mocktransponder_test.go +32 -0
- data/ext/vendor/golang.org/x/net/ipv6/multicast_test.go +264 -0
- data/ext/vendor/golang.org/x/net/ipv6/multicastlistener_test.go +261 -0
- data/ext/vendor/golang.org/x/net/ipv6/multicastsockopt_test.go +157 -0
- data/ext/vendor/golang.org/x/net/ipv6/payload.go +23 -0
- data/ext/vendor/golang.org/x/net/ipv6/payload_cmsg.go +35 -0
- data/ext/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_8.go +55 -0
- data/ext/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_9.go +57 -0
- data/ext/vendor/golang.org/x/net/ipv6/payload_nocmsg.go +41 -0
- data/ext/vendor/golang.org/x/net/ipv6/readwrite_go1_8_test.go +242 -0
- data/ext/vendor/golang.org/x/net/ipv6/readwrite_go1_9_test.go +373 -0
- data/ext/vendor/golang.org/x/net/ipv6/readwrite_test.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv6/sockopt.go +43 -0
- data/ext/vendor/golang.org/x/net/ipv6/sockopt_posix.go +87 -0
- data/ext/vendor/golang.org/x/net/ipv6/sockopt_stub.go +46 -0
- data/ext/vendor/golang.org/x/net/ipv6/sockopt_test.go +133 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_asmreq.go +24 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_asmreq_stub.go +17 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_bpf.go +23 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_bpf_stub.go +16 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_bsd.go +57 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_darwin.go +106 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_freebsd.go +92 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_linux.go +74 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_solaris.go +74 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_ssmreq.go +54 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_ssmreq_stub.go +21 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_stub.go +13 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_windows.go +75 -0
- data/ext/vendor/golang.org/x/net/ipv6/unicast_test.go +184 -0
- data/ext/vendor/golang.org/x/net/ipv6/unicastsockopt_test.go +120 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_darwin.go +131 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go +88 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go +122 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go +124 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go +124 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_386.go +170 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go +170 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mips.go +170 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mipsle.go +170 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_ppc.go +170 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_netbsd.go +84 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_openbsd.go +93 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_solaris.go +131 -0
- data/ext/vendor/golang.org/x/net/lex/httplex/httplex.go +351 -0
- data/ext/vendor/golang.org/x/net/lex/httplex/httplex_test.go +119 -0
- data/ext/vendor/golang.org/x/net/lif/address.go +105 -0
- data/ext/vendor/golang.org/x/net/lif/address_test.go +123 -0
- data/ext/vendor/golang.org/x/net/lif/binary.go +115 -0
- data/ext/vendor/golang.org/x/net/lif/defs_solaris.go +90 -0
- data/ext/vendor/golang.org/x/net/lif/lif.go +43 -0
- data/ext/vendor/golang.org/x/net/lif/link.go +126 -0
- data/ext/vendor/golang.org/x/net/lif/link_test.go +63 -0
- data/ext/vendor/golang.org/x/net/lif/sys.go +21 -0
- data/ext/vendor/golang.org/x/net/lif/sys_solaris_amd64.s +8 -0
- data/ext/vendor/golang.org/x/net/lif/syscall.go +28 -0
- data/ext/vendor/golang.org/x/net/lif/zsys_solaris_amd64.go +103 -0
- data/ext/vendor/golang.org/x/net/nettest/conntest.go +456 -0
- data/ext/vendor/golang.org/x/net/nettest/conntest_go16.go +24 -0
- data/ext/vendor/golang.org/x/net/nettest/conntest_go17.go +24 -0
- data/ext/vendor/golang.org/x/net/nettest/conntest_test.go +76 -0
- data/ext/vendor/golang.org/x/net/netutil/listen.go +48 -0
- data/ext/vendor/golang.org/x/net/netutil/listen_test.go +101 -0
- data/ext/vendor/golang.org/x/net/proxy/direct.go +18 -0
- data/ext/vendor/golang.org/x/net/proxy/per_host.go +140 -0
- data/ext/vendor/golang.org/x/net/proxy/per_host_test.go +55 -0
- data/ext/vendor/golang.org/x/net/proxy/proxy.go +134 -0
- data/ext/vendor/golang.org/x/net/proxy/proxy_test.go +215 -0
- data/ext/vendor/golang.org/x/net/proxy/socks5.go +214 -0
- data/ext/vendor/golang.org/x/net/publicsuffix/gen.go +713 -0
- data/ext/vendor/golang.org/x/net/publicsuffix/list.go +135 -0
- data/ext/vendor/golang.org/x/net/publicsuffix/list_test.go +416 -0
- data/ext/vendor/golang.org/x/net/publicsuffix/table.go +9419 -0
- data/ext/vendor/golang.org/x/net/publicsuffix/table_test.go +16756 -0
- data/ext/vendor/golang.org/x/net/route/address.go +425 -0
- data/ext/vendor/golang.org/x/net/route/address_darwin_test.go +63 -0
- data/ext/vendor/golang.org/x/net/route/address_test.go +103 -0
- data/ext/vendor/golang.org/x/net/route/binary.go +90 -0
- data/ext/vendor/golang.org/x/net/route/defs_darwin.go +114 -0
- data/ext/vendor/golang.org/x/net/route/defs_dragonfly.go +113 -0
- data/ext/vendor/golang.org/x/net/route/defs_freebsd.go +337 -0
- data/ext/vendor/golang.org/x/net/route/defs_netbsd.go +112 -0
- data/ext/vendor/golang.org/x/net/route/defs_openbsd.go +116 -0
- data/ext/vendor/golang.org/x/net/route/interface.go +64 -0
- data/ext/vendor/golang.org/x/net/route/interface_announce.go +32 -0
- data/ext/vendor/golang.org/x/net/route/interface_classic.go +66 -0
- data/ext/vendor/golang.org/x/net/route/interface_freebsd.go +78 -0
- data/ext/vendor/golang.org/x/net/route/interface_multicast.go +30 -0
- data/ext/vendor/golang.org/x/net/route/interface_openbsd.go +90 -0
- data/ext/vendor/golang.org/x/net/route/message.go +72 -0
- data/ext/vendor/golang.org/x/net/route/message_darwin_test.go +34 -0
- data/ext/vendor/golang.org/x/net/route/message_freebsd_test.go +92 -0
- data/ext/vendor/golang.org/x/net/route/message_test.go +239 -0
- data/ext/vendor/golang.org/x/net/route/route.go +123 -0
- data/ext/vendor/golang.org/x/net/route/route_classic.go +67 -0
- data/ext/vendor/golang.org/x/net/route/route_openbsd.go +65 -0
- data/ext/vendor/golang.org/x/net/route/route_test.go +390 -0
- data/ext/vendor/golang.org/x/net/route/sys.go +39 -0
- data/ext/vendor/golang.org/x/net/route/sys_darwin.go +87 -0
- data/ext/vendor/golang.org/x/net/route/sys_dragonfly.go +76 -0
- data/ext/vendor/golang.org/x/net/route/sys_freebsd.go +155 -0
- data/ext/vendor/golang.org/x/net/route/sys_netbsd.go +71 -0
- data/ext/vendor/golang.org/x/net/route/sys_openbsd.go +80 -0
- data/ext/vendor/golang.org/x/net/route/syscall.go +28 -0
- data/ext/vendor/golang.org/x/net/route/zsys_darwin.go +99 -0
- data/ext/vendor/golang.org/x/net/route/zsys_dragonfly.go +98 -0
- data/ext/vendor/golang.org/x/net/route/zsys_freebsd_386.go +126 -0
- data/ext/vendor/golang.org/x/net/route/zsys_freebsd_amd64.go +123 -0
- data/ext/vendor/golang.org/x/net/route/zsys_freebsd_arm.go +123 -0
- data/ext/vendor/golang.org/x/net/route/zsys_netbsd.go +97 -0
- data/ext/vendor/golang.org/x/net/route/zsys_openbsd.go +101 -0
- data/ext/vendor/golang.org/x/net/trace/events.go +532 -0
- data/ext/vendor/golang.org/x/net/trace/histogram.go +365 -0
- data/ext/vendor/golang.org/x/net/trace/histogram_test.go +325 -0
- data/ext/vendor/golang.org/x/net/trace/trace.go +1082 -0
- data/ext/vendor/golang.org/x/net/trace/trace_go16.go +21 -0
- data/ext/vendor/golang.org/x/net/trace/trace_go17.go +21 -0
- data/ext/vendor/golang.org/x/net/trace/trace_test.go +178 -0
- data/ext/vendor/golang.org/x/net/webdav/file.go +796 -0
- data/ext/vendor/golang.org/x/net/webdav/file_go1.6.go +17 -0
- data/ext/vendor/golang.org/x/net/webdav/file_go1.7.go +16 -0
- data/ext/vendor/golang.org/x/net/webdav/file_test.go +1184 -0
- data/ext/vendor/golang.org/x/net/webdav/if.go +173 -0
- data/ext/vendor/golang.org/x/net/webdav/if_test.go +322 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/README +11 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/atom_test.go +56 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/example_test.go +151 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/marshal.go +1223 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/marshal_test.go +1939 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/read.go +692 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/read_test.go +744 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/typeinfo.go +371 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/xml.go +1998 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/xml_test.go +752 -0
- data/ext/vendor/golang.org/x/net/webdav/litmus_test_server.go +94 -0
- data/ext/vendor/golang.org/x/net/webdav/lock.go +445 -0
- data/ext/vendor/golang.org/x/net/webdav/lock_test.go +731 -0
- data/ext/vendor/golang.org/x/net/webdav/prop.go +418 -0
- data/ext/vendor/golang.org/x/net/webdav/prop_test.go +613 -0
- data/ext/vendor/golang.org/x/net/webdav/webdav.go +702 -0
- data/ext/vendor/golang.org/x/net/webdav/webdav_test.go +344 -0
- data/ext/vendor/golang.org/x/net/webdav/xml.go +519 -0
- data/ext/vendor/golang.org/x/net/webdav/xml_test.go +906 -0
- data/ext/vendor/golang.org/x/net/websocket/client.go +106 -0
- data/ext/vendor/golang.org/x/net/websocket/dial.go +24 -0
- data/ext/vendor/golang.org/x/net/websocket/dial_test.go +43 -0
- data/ext/vendor/golang.org/x/net/websocket/exampledial_test.go +31 -0
- data/ext/vendor/golang.org/x/net/websocket/examplehandler_test.go +26 -0
- data/ext/vendor/golang.org/x/net/websocket/hybi.go +583 -0
- data/ext/vendor/golang.org/x/net/websocket/hybi_test.go +608 -0
- data/ext/vendor/golang.org/x/net/websocket/server.go +113 -0
- data/ext/vendor/golang.org/x/net/websocket/websocket.go +448 -0
- data/ext/vendor/golang.org/x/net/websocket/websocket_test.go +665 -0
- data/ext/vendor/golang.org/x/net/xsrftoken/xsrf.go +94 -0
- data/ext/vendor/golang.org/x/net/xsrftoken/xsrf_test.go +83 -0
- data/ext/vendor/golang.org/x/text/AUTHORS +3 -0
- data/ext/vendor/golang.org/x/text/CONTRIBUTING.md +31 -0
- data/ext/vendor/golang.org/x/text/CONTRIBUTORS +3 -0
- data/ext/vendor/golang.org/x/text/LICENSE +27 -0
- data/ext/vendor/golang.org/x/text/PATENTS +22 -0
- data/ext/vendor/golang.org/x/text/README.md +91 -0
- data/ext/vendor/golang.org/x/text/cases/cases.go +162 -0
- data/ext/vendor/golang.org/x/text/cases/context.go +376 -0
- data/ext/vendor/golang.org/x/text/cases/context_test.go +438 -0
- data/ext/vendor/golang.org/x/text/cases/example_test.go +53 -0
- data/ext/vendor/golang.org/x/text/cases/fold.go +34 -0
- data/ext/vendor/golang.org/x/text/cases/fold_test.go +51 -0
- data/ext/vendor/golang.org/x/text/cases/gen.go +839 -0
- data/ext/vendor/golang.org/x/text/cases/gen_trieval.go +219 -0
- data/ext/vendor/golang.org/x/text/cases/icu.go +61 -0
- data/ext/vendor/golang.org/x/text/cases/icu_test.go +210 -0
- data/ext/vendor/golang.org/x/text/cases/info.go +82 -0
- data/ext/vendor/golang.org/x/text/cases/map.go +816 -0
- data/ext/vendor/golang.org/x/text/cases/map_test.go +950 -0
- data/ext/vendor/golang.org/x/text/cases/tables.go +2251 -0
- data/ext/vendor/golang.org/x/text/cases/tables_test.go +1158 -0
- data/ext/vendor/golang.org/x/text/cases/trieval.go +215 -0
- data/ext/vendor/golang.org/x/text/cmd/gotext/doc.go +35 -0
- data/ext/vendor/golang.org/x/text/cmd/gotext/extract.go +195 -0
- data/ext/vendor/golang.org/x/text/cmd/gotext/main.go +356 -0
- data/ext/vendor/golang.org/x/text/cmd/gotext/message.go +127 -0
- data/ext/vendor/golang.org/x/text/codereview.cfg +1 -0
- data/ext/vendor/golang.org/x/text/collate/build/builder.go +702 -0
- data/ext/vendor/golang.org/x/text/collate/build/builder_test.go +290 -0
- data/ext/vendor/golang.org/x/text/collate/build/colelem.go +294 -0
- data/ext/vendor/golang.org/x/text/collate/build/colelem_test.go +215 -0
- data/ext/vendor/golang.org/x/text/collate/build/contract.go +309 -0
- data/ext/vendor/golang.org/x/text/collate/build/contract_test.go +266 -0
- data/ext/vendor/golang.org/x/text/collate/build/order.go +393 -0
- data/ext/vendor/golang.org/x/text/collate/build/order_test.go +229 -0
- data/ext/vendor/golang.org/x/text/collate/build/table.go +81 -0
- data/ext/vendor/golang.org/x/text/collate/build/trie.go +290 -0
- data/ext/vendor/golang.org/x/text/collate/build/trie_test.go +107 -0
- data/ext/vendor/golang.org/x/text/collate/collate.go +403 -0
- data/ext/vendor/golang.org/x/text/collate/collate_test.go +482 -0
- data/ext/vendor/golang.org/x/text/collate/export_test.go +51 -0
- data/ext/vendor/golang.org/x/text/collate/index.go +32 -0
- data/ext/vendor/golang.org/x/text/collate/maketables.go +553 -0
- data/ext/vendor/golang.org/x/text/collate/option.go +239 -0
- data/ext/vendor/golang.org/x/text/collate/option_test.go +209 -0
- data/ext/vendor/golang.org/x/text/collate/reg_test.go +230 -0
- data/ext/vendor/golang.org/x/text/collate/sort.go +81 -0
- data/ext/vendor/golang.org/x/text/collate/sort_test.go +55 -0
- data/ext/vendor/golang.org/x/text/collate/table_test.go +291 -0
- data/ext/vendor/golang.org/x/text/collate/tables.go +73789 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/Makefile +7 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/chars.go +1156 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/col.go +97 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/colcmp.go +529 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/darwin.go +111 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/gen.go +183 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/icu.go +209 -0
- data/ext/vendor/golang.org/x/text/currency/common.go +66 -0
- data/ext/vendor/golang.org/x/text/currency/currency.go +185 -0
- data/ext/vendor/golang.org/x/text/currency/currency_test.go +171 -0
- data/ext/vendor/golang.org/x/text/currency/example_test.go +27 -0
- data/ext/vendor/golang.org/x/text/currency/format.go +215 -0
- data/ext/vendor/golang.org/x/text/currency/format_test.go +70 -0
- data/ext/vendor/golang.org/x/text/currency/gen.go +400 -0
- data/ext/vendor/golang.org/x/text/currency/gen_common.go +70 -0
- data/ext/vendor/golang.org/x/text/currency/query.go +152 -0
- data/ext/vendor/golang.org/x/text/currency/query_test.go +107 -0
- data/ext/vendor/golang.org/x/text/currency/tables.go +2574 -0
- data/ext/vendor/golang.org/x/text/currency/tables_test.go +93 -0
- data/ext/vendor/golang.org/x/text/doc.go +13 -0
- data/ext/vendor/golang.org/x/text/encoding/charmap/charmap.go +249 -0
- data/ext/vendor/golang.org/x/text/encoding/charmap/charmap_test.go +258 -0
- data/ext/vendor/golang.org/x/text/encoding/charmap/maketables.go +556 -0
- data/ext/vendor/golang.org/x/text/encoding/charmap/tables.go +7410 -0
- data/ext/vendor/golang.org/x/text/encoding/encoding.go +335 -0
- data/ext/vendor/golang.org/x/text/encoding/encoding_test.go +290 -0
- data/ext/vendor/golang.org/x/text/encoding/example_test.go +42 -0
- data/ext/vendor/golang.org/x/text/encoding/htmlindex/gen.go +173 -0
- data/ext/vendor/golang.org/x/text/encoding/htmlindex/htmlindex.go +86 -0
- data/ext/vendor/golang.org/x/text/encoding/htmlindex/htmlindex_test.go +144 -0
- data/ext/vendor/golang.org/x/text/encoding/htmlindex/map.go +105 -0
- data/ext/vendor/golang.org/x/text/encoding/htmlindex/tables.go +352 -0
- data/ext/vendor/golang.org/x/text/encoding/ianaindex/example_test.go +27 -0
- data/ext/vendor/golang.org/x/text/encoding/ianaindex/gen.go +192 -0
- data/ext/vendor/golang.org/x/text/encoding/ianaindex/ianaindex.go +209 -0
- data/ext/vendor/golang.org/x/text/encoding/ianaindex/ianaindex_test.go +192 -0
- data/ext/vendor/golang.org/x/text/encoding/ianaindex/tables.go +2348 -0
- data/ext/vendor/golang.org/x/text/encoding/internal/enctest/enctest.go +180 -0
- data/ext/vendor/golang.org/x/text/encoding/internal/identifier/gen.go +137 -0
- data/ext/vendor/golang.org/x/text/encoding/internal/identifier/identifier.go +81 -0
- data/ext/vendor/golang.org/x/text/encoding/internal/identifier/mib.go +1621 -0
- data/ext/vendor/golang.org/x/text/encoding/internal/internal.go +75 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/all.go +12 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/all_test.go +248 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/eucjp.go +225 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/iso2022jp.go +299 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/maketables.go +161 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/shiftjis.go +189 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/tables.go +26971 -0
- data/ext/vendor/golang.org/x/text/encoding/korean/all_test.go +94 -0
- data/ext/vendor/golang.org/x/text/encoding/korean/euckr.go +177 -0
- data/ext/vendor/golang.org/x/text/encoding/korean/maketables.go +143 -0
- data/ext/vendor/golang.org/x/text/encoding/korean/tables.go +34152 -0
- data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/all.go +12 -0
- data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/all_test.go +143 -0
- data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/gbk.go +269 -0
- data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go +245 -0
- data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/maketables.go +161 -0
- data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/tables.go +43999 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/candide-gb18030.txt +510 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/candide-utf-16le.txt +0 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/candide-utf-32be.txt +0 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/candide-utf-8.txt +510 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/candide-windows-1252.txt +510 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-euc-jp.txt +178 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-iso-2022-jp.txt +178 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-shift-jis.txt +178 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-utf-8.txt +178 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-gb-levels-1-and-2-hz-gb2312.txt +107 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-gb-levels-1-and-2-utf-8.txt +107 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-simplified-gbk.txt +107 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-simplified-utf-8.txt +107 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-traditional-big5.txt +106 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-traditional-utf-8.txt +106 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/unsu-joh-eun-nal-euc-kr.txt +175 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/unsu-joh-eun-nal-utf-8.txt +175 -0
- data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/all_test.go +114 -0
- data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/big5.go +199 -0
- data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/maketables.go +140 -0
- data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/tables.go +37142 -0
- data/ext/vendor/golang.org/x/text/encoding/unicode/override.go +82 -0
- data/ext/vendor/golang.org/x/text/encoding/unicode/unicode.go +434 -0
- data/ext/vendor/golang.org/x/text/encoding/unicode/unicode_test.go +499 -0
- data/ext/vendor/golang.org/x/text/encoding/unicode/utf32/utf32.go +296 -0
- data/ext/vendor/golang.org/x/text/encoding/unicode/utf32/utf32_test.go +248 -0
- data/ext/vendor/golang.org/x/text/feature/plural/common.go +70 -0
- data/ext/vendor/golang.org/x/text/feature/plural/data_test.go +190 -0
- data/ext/vendor/golang.org/x/text/feature/plural/example_test.go +46 -0
- data/ext/vendor/golang.org/x/text/feature/plural/gen.go +513 -0
- data/ext/vendor/golang.org/x/text/feature/plural/gen_common.go +74 -0
- data/ext/vendor/golang.org/x/text/feature/plural/message.go +244 -0
- data/ext/vendor/golang.org/x/text/feature/plural/message_test.go +197 -0
- data/ext/vendor/golang.org/x/text/feature/plural/plural.go +258 -0
- data/ext/vendor/golang.org/x/text/feature/plural/plural_test.go +216 -0
- data/ext/vendor/golang.org/x/text/feature/plural/tables.go +540 -0
- data/ext/vendor/golang.org/x/text/gen.go +318 -0
- data/ext/vendor/golang.org/x/text/internal/catmsg/catmsg.go +366 -0
- data/ext/vendor/golang.org/x/text/internal/catmsg/catmsg_test.go +316 -0
- data/ext/vendor/golang.org/x/text/internal/catmsg/codec.go +407 -0
- data/ext/vendor/golang.org/x/text/internal/catmsg/varint.go +62 -0
- data/ext/vendor/golang.org/x/text/internal/catmsg/varint_test.go +123 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/collate_test.go +121 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/collelem.go +371 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/collelem_test.go +183 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/colltab.go +105 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/colltab_test.go +64 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/contract.go +145 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/contract_test.go +131 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/iter.go +178 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/iter_test.go +63 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/numeric.go +236 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/numeric_test.go +159 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/table.go +275 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/trie.go +159 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/trie_test.go +106 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/weighter.go +31 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/weighter_test.go +42 -0
- data/ext/vendor/golang.org/x/text/internal/export/README +4 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/common_test.go +55 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/example_test.go +68 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/gen.go +276 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/gen_common.go +59 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/gen_test.go +91 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/gen_trieval.go +123 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/idna.go +717 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/idna_test.go +308 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/punycode.go +201 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/punycode_test.go +198 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/tables.go +4557 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/trie.go +70 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/trieval.go +119 -0
- data/ext/vendor/golang.org/x/text/internal/format/format.go +41 -0
- data/ext/vendor/golang.org/x/text/internal/gen.go +52 -0
- data/ext/vendor/golang.org/x/text/internal/gen/code.go +351 -0
- data/ext/vendor/golang.org/x/text/internal/gen/gen.go +281 -0
- data/ext/vendor/golang.org/x/text/internal/gen_test.go +38 -0
- data/ext/vendor/golang.org/x/text/internal/internal.go +51 -0
- data/ext/vendor/golang.org/x/text/internal/internal_test.go +38 -0
- data/ext/vendor/golang.org/x/text/internal/match.go +67 -0
- data/ext/vendor/golang.org/x/text/internal/match_test.go +56 -0
- data/ext/vendor/golang.org/x/text/internal/number/common.go +40 -0
- data/ext/vendor/golang.org/x/text/internal/number/decimal.go +498 -0
- data/ext/vendor/golang.org/x/text/internal/number/decimal_test.go +329 -0
- data/ext/vendor/golang.org/x/text/internal/number/format.go +540 -0
- data/ext/vendor/golang.org/x/text/internal/number/format_test.go +522 -0
- data/ext/vendor/golang.org/x/text/internal/number/gen.go +458 -0
- data/ext/vendor/golang.org/x/text/internal/number/gen_common.go +44 -0
- data/ext/vendor/golang.org/x/text/internal/number/number.go +154 -0
- data/ext/vendor/golang.org/x/text/internal/number/number_test.go +100 -0
- data/ext/vendor/golang.org/x/text/internal/number/pattern.go +485 -0
- data/ext/vendor/golang.org/x/text/internal/number/pattern_test.go +438 -0
- data/ext/vendor/golang.org/x/text/internal/number/roundingmode_string.go +16 -0
- data/ext/vendor/golang.org/x/text/internal/number/tables.go +1154 -0
- data/ext/vendor/golang.org/x/text/internal/number/tables_test.go +125 -0
- data/ext/vendor/golang.org/x/text/internal/stringset/set.go +86 -0
- data/ext/vendor/golang.org/x/text/internal/stringset/set_test.go +53 -0
- data/ext/vendor/golang.org/x/text/internal/tables.go +117 -0
- data/ext/vendor/golang.org/x/text/internal/tag/tag.go +100 -0
- data/ext/vendor/golang.org/x/text/internal/tag/tag_test.go +67 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/codesize.go +53 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/flag.go +22 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/gc.go +14 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/gccgo.go +11 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/go1_6.go +23 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/go1_7.go +17 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/text.go +105 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/compact.go +58 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/data_test.go +875 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/example_compact_test.go +71 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/example_test.go +148 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/gen_test.go +68 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/print.go +251 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/triegen.go +494 -0
- data/ext/vendor/golang.org/x/text/internal/ucd/example_test.go +81 -0
- data/ext/vendor/golang.org/x/text/internal/ucd/ucd.go +371 -0
- data/ext/vendor/golang.org/x/text/internal/ucd/ucd_test.go +105 -0
- data/ext/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go +87 -0
- data/ext/vendor/golang.org/x/text/language/Makefile +16 -0
- data/ext/vendor/golang.org/x/text/language/common.go +16 -0
- data/ext/vendor/golang.org/x/text/language/coverage.go +197 -0
- data/ext/vendor/golang.org/x/text/language/coverage_test.go +154 -0
- data/ext/vendor/golang.org/x/text/language/display/dict.go +92 -0
- data/ext/vendor/golang.org/x/text/language/display/dict_test.go +39 -0
- data/ext/vendor/golang.org/x/text/language/display/display.go +420 -0
- data/ext/vendor/golang.org/x/text/language/display/display_test.go +705 -0
- data/ext/vendor/golang.org/x/text/language/display/examples_test.go +116 -0
- data/ext/vendor/golang.org/x/text/language/display/lookup.go +251 -0
- data/ext/vendor/golang.org/x/text/language/display/maketables.go +602 -0
- data/ext/vendor/golang.org/x/text/language/display/tables.go +50344 -0
- data/ext/vendor/golang.org/x/text/language/doc.go +102 -0
- data/ext/vendor/golang.org/x/text/language/examples_test.go +413 -0
- data/ext/vendor/golang.org/x/text/language/gen.go +1706 -0
- data/ext/vendor/golang.org/x/text/language/gen_common.go +20 -0
- data/ext/vendor/golang.org/x/text/language/gen_index.go +162 -0
- data/ext/vendor/golang.org/x/text/language/go1_1.go +38 -0
- data/ext/vendor/golang.org/x/text/language/go1_2.go +11 -0
- data/ext/vendor/golang.org/x/text/language/httpexample_test.go +48 -0
- data/ext/vendor/golang.org/x/text/language/index.go +769 -0
- data/ext/vendor/golang.org/x/text/language/language.go +887 -0
- data/ext/vendor/golang.org/x/text/language/language_test.go +878 -0
- data/ext/vendor/golang.org/x/text/language/lookup.go +396 -0
- data/ext/vendor/golang.org/x/text/language/lookup_test.go +457 -0
- data/ext/vendor/golang.org/x/text/language/match.go +933 -0
- data/ext/vendor/golang.org/x/text/language/match_test.go +505 -0
- data/ext/vendor/golang.org/x/text/language/parse.go +859 -0
- data/ext/vendor/golang.org/x/text/language/parse_test.go +517 -0
- data/ext/vendor/golang.org/x/text/language/tables.go +3675 -0
- data/ext/vendor/golang.org/x/text/language/tags.go +143 -0
- data/ext/vendor/golang.org/x/text/language/testdata/CLDRLocaleMatcherTest.txt +389 -0
- data/ext/vendor/golang.org/x/text/language/testdata/GoLocaleMatcherTest.txt +226 -0
- data/ext/vendor/golang.org/x/text/message/catalog.go +28 -0
- data/ext/vendor/golang.org/x/text/message/catalog/catalog.go +292 -0
- data/ext/vendor/golang.org/x/text/message/catalog/catalog_test.go +194 -0
- data/ext/vendor/golang.org/x/text/message/catalog/dict.go +90 -0
- data/ext/vendor/golang.org/x/text/message/doc.go +100 -0
- data/ext/vendor/golang.org/x/text/message/examples_test.go +42 -0
- data/ext/vendor/golang.org/x/text/message/fmt_test.go +1889 -0
- data/ext/vendor/golang.org/x/text/message/format.go +532 -0
- data/ext/vendor/golang.org/x/text/message/message.go +169 -0
- data/ext/vendor/golang.org/x/text/message/message_test.go +181 -0
- data/ext/vendor/golang.org/x/text/message/print.go +1194 -0
- data/ext/vendor/golang.org/x/text/number/doc.go +28 -0
- data/ext/vendor/golang.org/x/text/number/examples_test.go +28 -0
- data/ext/vendor/golang.org/x/text/number/format.go +122 -0
- data/ext/vendor/golang.org/x/text/number/format_test.go +107 -0
- data/ext/vendor/golang.org/x/text/number/number.go +77 -0
- data/ext/vendor/golang.org/x/text/number/number_test.go +190 -0
- data/ext/vendor/golang.org/x/text/number/option.go +177 -0
- data/ext/vendor/golang.org/x/text/runes/cond.go +187 -0
- data/ext/vendor/golang.org/x/text/runes/cond_test.go +282 -0
- data/ext/vendor/golang.org/x/text/runes/example_test.go +60 -0
- data/ext/vendor/golang.org/x/text/runes/runes.go +355 -0
- data/ext/vendor/golang.org/x/text/runes/runes_test.go +664 -0
- data/ext/vendor/golang.org/x/text/search/index.go +35 -0
- data/ext/vendor/golang.org/x/text/search/pattern.go +155 -0
- data/ext/vendor/golang.org/x/text/search/pattern_test.go +357 -0
- data/ext/vendor/golang.org/x/text/search/search.go +237 -0
- data/ext/vendor/golang.org/x/text/search/tables.go +12448 -0
- data/ext/vendor/golang.org/x/text/secure/bidirule/bench_test.go +54 -0
- data/ext/vendor/golang.org/x/text/secure/bidirule/bidirule.go +340 -0
- data/ext/vendor/golang.org/x/text/secure/bidirule/bidirule_test.go +851 -0
- data/ext/vendor/golang.org/x/text/secure/doc.go +6 -0
- data/ext/vendor/golang.org/x/text/secure/precis/benchmark_test.go +82 -0
- data/ext/vendor/golang.org/x/text/secure/precis/class.go +36 -0
- data/ext/vendor/golang.org/x/text/secure/precis/class_test.go +50 -0
- data/ext/vendor/golang.org/x/text/secure/precis/context.go +139 -0
- data/ext/vendor/golang.org/x/text/secure/precis/doc.go +14 -0
- data/ext/vendor/golang.org/x/text/secure/precis/enforce_test.go +396 -0
- data/ext/vendor/golang.org/x/text/secure/precis/gen.go +310 -0
- data/ext/vendor/golang.org/x/text/secure/precis/gen_trieval.go +68 -0
- data/ext/vendor/golang.org/x/text/secure/precis/nickname.go +72 -0
- data/ext/vendor/golang.org/x/text/secure/precis/options.go +157 -0
- data/ext/vendor/golang.org/x/text/secure/precis/profile.go +402 -0
- data/ext/vendor/golang.org/x/text/secure/precis/profile_test.go +149 -0
- data/ext/vendor/golang.org/x/text/secure/precis/profiles.go +78 -0
- data/ext/vendor/golang.org/x/text/secure/precis/tables.go +3887 -0
- data/ext/vendor/golang.org/x/text/secure/precis/tables_test.go +69 -0
- data/ext/vendor/golang.org/x/text/secure/precis/transformer.go +32 -0
- data/ext/vendor/golang.org/x/text/secure/precis/trieval.go +64 -0
- data/ext/vendor/golang.org/x/text/transform/examples_test.go +37 -0
- data/ext/vendor/golang.org/x/text/transform/transform.go +705 -0
- data/ext/vendor/golang.org/x/text/transform/transform_test.go +1317 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/bidi.go +198 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/bracket.go +335 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/core.go +1058 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/core_test.go +224 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/gen.go +133 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/gen_ranges.go +57 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/gen_trieval.go +64 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/prop.go +206 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/ranges_test.go +53 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/tables.go +1813 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/tables_test.go +82 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/trieval.go +60 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/base.go +100 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/cldr.go +130 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/cldr_test.go +27 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/collate.go +359 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/collate_test.go +275 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/data_test.go +186 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/decode.go +171 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/examples_test.go +21 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/makexml.go +400 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/resolve.go +602 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/resolve_test.go +368 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/slice.go +144 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/slice_test.go +175 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/xml.go +1487 -0
- data/ext/vendor/golang.org/x/text/unicode/doc.go +8 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/composition.go +508 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/composition_test.go +130 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/example_iter_test.go +82 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/example_test.go +27 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/forminfo.go +259 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/forminfo_test.go +54 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/input.go +109 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/iter.go +457 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/iter_test.go +98 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/maketables.go +976 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/norm_test.go +14 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/normalize.go +609 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/normalize_test.go +1287 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/readwriter.go +125 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/readwriter_test.go +56 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/tables.go +7651 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/transform.go +88 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/transform_test.go +101 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/trie.go +54 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/triegen.go +117 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/ucd_test.go +275 -0
- data/ext/vendor/golang.org/x/text/unicode/rangetable/gen.go +115 -0
- data/ext/vendor/golang.org/x/text/unicode/rangetable/merge.go +260 -0
- data/ext/vendor/golang.org/x/text/unicode/rangetable/merge_test.go +184 -0
- data/ext/vendor/golang.org/x/text/unicode/rangetable/rangetable.go +70 -0
- data/ext/vendor/golang.org/x/text/unicode/rangetable/rangetable_test.go +55 -0
- data/ext/vendor/golang.org/x/text/unicode/rangetable/tables.go +6376 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/bits.go +59 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/example_test.go +118 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/gen.go +195 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/gen_bits.go +63 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/runenames.go +48 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/runenames_test.go +46 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/tables.go +15514 -0
- data/ext/vendor/golang.org/x/text/width/common_test.go +92 -0
- data/ext/vendor/golang.org/x/text/width/example_test.go +52 -0
- data/ext/vendor/golang.org/x/text/width/gen.go +115 -0
- data/ext/vendor/golang.org/x/text/width/gen_common.go +96 -0
- data/ext/vendor/golang.org/x/text/width/gen_trieval.go +34 -0
- data/ext/vendor/golang.org/x/text/width/kind_string.go +16 -0
- data/ext/vendor/golang.org/x/text/width/runes_test.go +461 -0
- data/ext/vendor/golang.org/x/text/width/tables.go +1316 -0
- data/ext/vendor/golang.org/x/text/width/tables_test.go +59 -0
- data/ext/vendor/golang.org/x/text/width/transform.go +239 -0
- data/ext/vendor/golang.org/x/text/width/transform_test.go +701 -0
- data/ext/vendor/golang.org/x/text/width/trieval.go +30 -0
- data/ext/vendor/golang.org/x/text/width/width.go +206 -0
- data/lib/ires/version.rb +1 -1
- data/shared/darwin/ires.so +0 -0
- data/shared/linux/ires.so +0 -0
- metadata +1011 -23
- data/ext/operate/image.go +0 -176
- data/ext/util/uri/uri.go +0 -105
- data/ext/vendor/github.com/satori/go.uuid/README.md +0 -65
- data/ext/vendor/github.com/satori/go.uuid/benchmarks_test.go +0 -121
- data/ext/vendor/github.com/satori/go.uuid/uuid.go +0 -488
- data/ext/vendor/github.com/satori/go.uuid/uuid_test.go +0 -633
@@ -0,0 +1,2285 @@
|
|
1
|
+
// Copyright 2015 The Go Authors. All rights reserved.
|
2
|
+
// Use of this source code is governed by a BSD-style
|
3
|
+
// license that can be found in the LICENSE file.
|
4
|
+
|
5
|
+
// Transport code.
|
6
|
+
|
7
|
+
package http2
|
8
|
+
|
9
|
+
import (
|
10
|
+
"bufio"
|
11
|
+
"bytes"
|
12
|
+
"compress/gzip"
|
13
|
+
"crypto/rand"
|
14
|
+
"crypto/tls"
|
15
|
+
"errors"
|
16
|
+
"fmt"
|
17
|
+
"io"
|
18
|
+
"io/ioutil"
|
19
|
+
"log"
|
20
|
+
"math"
|
21
|
+
mathrand "math/rand"
|
22
|
+
"net"
|
23
|
+
"net/http"
|
24
|
+
"sort"
|
25
|
+
"strconv"
|
26
|
+
"strings"
|
27
|
+
"sync"
|
28
|
+
"time"
|
29
|
+
|
30
|
+
"golang.org/x/net/http2/hpack"
|
31
|
+
"golang.org/x/net/idna"
|
32
|
+
"golang.org/x/net/lex/httplex"
|
33
|
+
)
|
34
|
+
|
35
|
+
const (
|
36
|
+
// transportDefaultConnFlow is how many connection-level flow control
|
37
|
+
// tokens we give the server at start-up, past the default 64k.
|
38
|
+
transportDefaultConnFlow = 1 << 30
|
39
|
+
|
40
|
+
// transportDefaultStreamFlow is how many stream-level flow
|
41
|
+
// control tokens we announce to the peer, and how many bytes
|
42
|
+
// we buffer per stream.
|
43
|
+
transportDefaultStreamFlow = 4 << 20
|
44
|
+
|
45
|
+
// transportDefaultStreamMinRefresh is the minimum number of bytes we'll send
|
46
|
+
// a stream-level WINDOW_UPDATE for at a time.
|
47
|
+
transportDefaultStreamMinRefresh = 4 << 10
|
48
|
+
|
49
|
+
defaultUserAgent = "Go-http-client/2.0"
|
50
|
+
)
|
51
|
+
|
52
|
+
// Transport is an HTTP/2 Transport.
|
53
|
+
//
|
54
|
+
// A Transport internally caches connections to servers. It is safe
|
55
|
+
// for concurrent use by multiple goroutines.
|
56
|
+
type Transport struct {
|
57
|
+
// DialTLS specifies an optional dial function for creating
|
58
|
+
// TLS connections for requests.
|
59
|
+
//
|
60
|
+
// If DialTLS is nil, tls.Dial is used.
|
61
|
+
//
|
62
|
+
// If the returned net.Conn has a ConnectionState method like tls.Conn,
|
63
|
+
// it will be used to set http.Response.TLS.
|
64
|
+
DialTLS func(network, addr string, cfg *tls.Config) (net.Conn, error)
|
65
|
+
|
66
|
+
// TLSClientConfig specifies the TLS configuration to use with
|
67
|
+
// tls.Client. If nil, the default configuration is used.
|
68
|
+
TLSClientConfig *tls.Config
|
69
|
+
|
70
|
+
// ConnPool optionally specifies an alternate connection pool to use.
|
71
|
+
// If nil, the default is used.
|
72
|
+
ConnPool ClientConnPool
|
73
|
+
|
74
|
+
// DisableCompression, if true, prevents the Transport from
|
75
|
+
// requesting compression with an "Accept-Encoding: gzip"
|
76
|
+
// request header when the Request contains no existing
|
77
|
+
// Accept-Encoding value. If the Transport requests gzip on
|
78
|
+
// its own and gets a gzipped response, it's transparently
|
79
|
+
// decoded in the Response.Body. However, if the user
|
80
|
+
// explicitly requested gzip it is not automatically
|
81
|
+
// uncompressed.
|
82
|
+
DisableCompression bool
|
83
|
+
|
84
|
+
// AllowHTTP, if true, permits HTTP/2 requests using the insecure,
|
85
|
+
// plain-text "http" scheme. Note that this does not enable h2c support.
|
86
|
+
AllowHTTP bool
|
87
|
+
|
88
|
+
// MaxHeaderListSize is the http2 SETTINGS_MAX_HEADER_LIST_SIZE to
|
89
|
+
// send in the initial settings frame. It is how many bytes
|
90
|
+
// of response headers are allowed. Unlike the http2 spec, zero here
|
91
|
+
// means to use a default limit (currently 10MB). If you actually
|
92
|
+
// want to advertise an ulimited value to the peer, Transport
|
93
|
+
// interprets the highest possible value here (0xffffffff or 1<<32-1)
|
94
|
+
// to mean no limit.
|
95
|
+
MaxHeaderListSize uint32
|
96
|
+
|
97
|
+
// t1, if non-nil, is the standard library Transport using
|
98
|
+
// this transport. Its settings are used (but not its
|
99
|
+
// RoundTrip method, etc).
|
100
|
+
t1 *http.Transport
|
101
|
+
|
102
|
+
connPoolOnce sync.Once
|
103
|
+
connPoolOrDef ClientConnPool // non-nil version of ConnPool
|
104
|
+
}
|
105
|
+
|
106
|
+
func (t *Transport) maxHeaderListSize() uint32 {
|
107
|
+
if t.MaxHeaderListSize == 0 {
|
108
|
+
return 10 << 20
|
109
|
+
}
|
110
|
+
if t.MaxHeaderListSize == 0xffffffff {
|
111
|
+
return 0
|
112
|
+
}
|
113
|
+
return t.MaxHeaderListSize
|
114
|
+
}
|
115
|
+
|
116
|
+
func (t *Transport) disableCompression() bool {
|
117
|
+
return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression)
|
118
|
+
}
|
119
|
+
|
120
|
+
var errTransportVersion = errors.New("http2: ConfigureTransport is only supported starting at Go 1.6")
|
121
|
+
|
122
|
+
// ConfigureTransport configures a net/http HTTP/1 Transport to use HTTP/2.
|
123
|
+
// It requires Go 1.6 or later and returns an error if the net/http package is too old
|
124
|
+
// or if t1 has already been HTTP/2-enabled.
|
125
|
+
func ConfigureTransport(t1 *http.Transport) error {
|
126
|
+
_, err := configureTransport(t1) // in configure_transport.go (go1.6) or not_go16.go
|
127
|
+
return err
|
128
|
+
}
|
129
|
+
|
130
|
+
func (t *Transport) connPool() ClientConnPool {
|
131
|
+
t.connPoolOnce.Do(t.initConnPool)
|
132
|
+
return t.connPoolOrDef
|
133
|
+
}
|
134
|
+
|
135
|
+
func (t *Transport) initConnPool() {
|
136
|
+
if t.ConnPool != nil {
|
137
|
+
t.connPoolOrDef = t.ConnPool
|
138
|
+
} else {
|
139
|
+
t.connPoolOrDef = &clientConnPool{t: t}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
// ClientConn is the state of a single HTTP/2 client connection to an
|
144
|
+
// HTTP/2 server.
|
145
|
+
type ClientConn struct {
|
146
|
+
t *Transport
|
147
|
+
tconn net.Conn // usually *tls.Conn, except specialized impls
|
148
|
+
tlsState *tls.ConnectionState // nil only for specialized impls
|
149
|
+
singleUse bool // whether being used for a single http.Request
|
150
|
+
|
151
|
+
// readLoop goroutine fields:
|
152
|
+
readerDone chan struct{} // closed on error
|
153
|
+
readerErr error // set before readerDone is closed
|
154
|
+
|
155
|
+
idleTimeout time.Duration // or 0 for never
|
156
|
+
idleTimer *time.Timer
|
157
|
+
|
158
|
+
mu sync.Mutex // guards following
|
159
|
+
cond *sync.Cond // hold mu; broadcast on flow/closed changes
|
160
|
+
flow flow // our conn-level flow control quota (cs.flow is per stream)
|
161
|
+
inflow flow // peer's conn-level flow control
|
162
|
+
closed bool
|
163
|
+
wantSettingsAck bool // we sent a SETTINGS frame and haven't heard back
|
164
|
+
goAway *GoAwayFrame // if non-nil, the GoAwayFrame we received
|
165
|
+
goAwayDebug string // goAway frame's debug data, retained as a string
|
166
|
+
streams map[uint32]*clientStream // client-initiated
|
167
|
+
nextStreamID uint32
|
168
|
+
pendingRequests int // requests blocked and waiting to be sent because len(streams) == maxConcurrentStreams
|
169
|
+
pings map[[8]byte]chan struct{} // in flight ping data to notification channel
|
170
|
+
bw *bufio.Writer
|
171
|
+
br *bufio.Reader
|
172
|
+
fr *Framer
|
173
|
+
lastActive time.Time
|
174
|
+
// Settings from peer: (also guarded by mu)
|
175
|
+
maxFrameSize uint32
|
176
|
+
maxConcurrentStreams uint32
|
177
|
+
peerMaxHeaderListSize uint64
|
178
|
+
initialWindowSize uint32
|
179
|
+
|
180
|
+
hbuf bytes.Buffer // HPACK encoder writes into this
|
181
|
+
henc *hpack.Encoder
|
182
|
+
freeBuf [][]byte
|
183
|
+
|
184
|
+
wmu sync.Mutex // held while writing; acquire AFTER mu if holding both
|
185
|
+
werr error // first write error that has occurred
|
186
|
+
}
|
187
|
+
|
188
|
+
// clientStream is the state for a single HTTP/2 stream. One of these
|
189
|
+
// is created for each Transport.RoundTrip call.
|
190
|
+
type clientStream struct {
|
191
|
+
cc *ClientConn
|
192
|
+
req *http.Request
|
193
|
+
trace *clientTrace // or nil
|
194
|
+
ID uint32
|
195
|
+
resc chan resAndError
|
196
|
+
bufPipe pipe // buffered pipe with the flow-controlled response payload
|
197
|
+
startedWrite bool // started request body write; guarded by cc.mu
|
198
|
+
requestedGzip bool
|
199
|
+
on100 func() // optional code to run if get a 100 continue response
|
200
|
+
|
201
|
+
flow flow // guarded by cc.mu
|
202
|
+
inflow flow // guarded by cc.mu
|
203
|
+
bytesRemain int64 // -1 means unknown; owned by transportResponseBody.Read
|
204
|
+
readErr error // sticky read error; owned by transportResponseBody.Read
|
205
|
+
stopReqBody error // if non-nil, stop writing req body; guarded by cc.mu
|
206
|
+
didReset bool // whether we sent a RST_STREAM to the server; guarded by cc.mu
|
207
|
+
|
208
|
+
peerReset chan struct{} // closed on peer reset
|
209
|
+
resetErr error // populated before peerReset is closed
|
210
|
+
|
211
|
+
done chan struct{} // closed when stream remove from cc.streams map; close calls guarded by cc.mu
|
212
|
+
|
213
|
+
// owned by clientConnReadLoop:
|
214
|
+
firstByte bool // got the first response byte
|
215
|
+
pastHeaders bool // got first MetaHeadersFrame (actual headers)
|
216
|
+
pastTrailers bool // got optional second MetaHeadersFrame (trailers)
|
217
|
+
|
218
|
+
trailer http.Header // accumulated trailers
|
219
|
+
resTrailer *http.Header // client's Response.Trailer
|
220
|
+
}
|
221
|
+
|
222
|
+
// awaitRequestCancel waits for the user to cancel a request or for the done
|
223
|
+
// channel to be signaled. A non-nil error is returned only if the request was
|
224
|
+
// canceled.
|
225
|
+
func awaitRequestCancel(req *http.Request, done <-chan struct{}) error {
|
226
|
+
ctx := reqContext(req)
|
227
|
+
if req.Cancel == nil && ctx.Done() == nil {
|
228
|
+
return nil
|
229
|
+
}
|
230
|
+
select {
|
231
|
+
case <-req.Cancel:
|
232
|
+
return errRequestCanceled
|
233
|
+
case <-ctx.Done():
|
234
|
+
return ctx.Err()
|
235
|
+
case <-done:
|
236
|
+
return nil
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
// awaitRequestCancel waits for the user to cancel a request, its context to
|
241
|
+
// expire, or for the request to be done (any way it might be removed from the
|
242
|
+
// cc.streams map: peer reset, successful completion, TCP connection breakage,
|
243
|
+
// etc). If the request is canceled, then cs will be canceled and closed.
|
244
|
+
func (cs *clientStream) awaitRequestCancel(req *http.Request) {
|
245
|
+
if err := awaitRequestCancel(req, cs.done); err != nil {
|
246
|
+
cs.cancelStream()
|
247
|
+
cs.bufPipe.CloseWithError(err)
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
func (cs *clientStream) cancelStream() {
|
252
|
+
cc := cs.cc
|
253
|
+
cc.mu.Lock()
|
254
|
+
didReset := cs.didReset
|
255
|
+
cs.didReset = true
|
256
|
+
cc.mu.Unlock()
|
257
|
+
|
258
|
+
if !didReset {
|
259
|
+
cc.writeStreamReset(cs.ID, ErrCodeCancel, nil)
|
260
|
+
cc.forgetStreamID(cs.ID)
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
// checkResetOrDone reports any error sent in a RST_STREAM frame by the
|
265
|
+
// server, or errStreamClosed if the stream is complete.
|
266
|
+
func (cs *clientStream) checkResetOrDone() error {
|
267
|
+
select {
|
268
|
+
case <-cs.peerReset:
|
269
|
+
return cs.resetErr
|
270
|
+
case <-cs.done:
|
271
|
+
return errStreamClosed
|
272
|
+
default:
|
273
|
+
return nil
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
func (cs *clientStream) abortRequestBodyWrite(err error) {
|
278
|
+
if err == nil {
|
279
|
+
panic("nil error")
|
280
|
+
}
|
281
|
+
cc := cs.cc
|
282
|
+
cc.mu.Lock()
|
283
|
+
cs.stopReqBody = err
|
284
|
+
cc.cond.Broadcast()
|
285
|
+
cc.mu.Unlock()
|
286
|
+
}
|
287
|
+
|
288
|
+
type stickyErrWriter struct {
|
289
|
+
w io.Writer
|
290
|
+
err *error
|
291
|
+
}
|
292
|
+
|
293
|
+
func (sew stickyErrWriter) Write(p []byte) (n int, err error) {
|
294
|
+
if *sew.err != nil {
|
295
|
+
return 0, *sew.err
|
296
|
+
}
|
297
|
+
n, err = sew.w.Write(p)
|
298
|
+
*sew.err = err
|
299
|
+
return
|
300
|
+
}
|
301
|
+
|
302
|
+
var ErrNoCachedConn = errors.New("http2: no cached connection was available")
|
303
|
+
|
304
|
+
// RoundTripOpt are options for the Transport.RoundTripOpt method.
|
305
|
+
type RoundTripOpt struct {
|
306
|
+
// OnlyCachedConn controls whether RoundTripOpt may
|
307
|
+
// create a new TCP connection. If set true and
|
308
|
+
// no cached connection is available, RoundTripOpt
|
309
|
+
// will return ErrNoCachedConn.
|
310
|
+
OnlyCachedConn bool
|
311
|
+
}
|
312
|
+
|
313
|
+
func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
314
|
+
return t.RoundTripOpt(req, RoundTripOpt{})
|
315
|
+
}
|
316
|
+
|
317
|
+
// authorityAddr returns a given authority (a host/IP, or host:port / ip:port)
|
318
|
+
// and returns a host:port. The port 443 is added if needed.
|
319
|
+
func authorityAddr(scheme string, authority string) (addr string) {
|
320
|
+
host, port, err := net.SplitHostPort(authority)
|
321
|
+
if err != nil { // authority didn't have a port
|
322
|
+
port = "443"
|
323
|
+
if scheme == "http" {
|
324
|
+
port = "80"
|
325
|
+
}
|
326
|
+
host = authority
|
327
|
+
}
|
328
|
+
if a, err := idna.ToASCII(host); err == nil {
|
329
|
+
host = a
|
330
|
+
}
|
331
|
+
// IPv6 address literal, without a port:
|
332
|
+
if strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]") {
|
333
|
+
return host + ":" + port
|
334
|
+
}
|
335
|
+
return net.JoinHostPort(host, port)
|
336
|
+
}
|
337
|
+
|
338
|
+
// RoundTripOpt is like RoundTrip, but takes options.
|
339
|
+
func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error) {
|
340
|
+
if !(req.URL.Scheme == "https" || (req.URL.Scheme == "http" && t.AllowHTTP)) {
|
341
|
+
return nil, errors.New("http2: unsupported scheme")
|
342
|
+
}
|
343
|
+
|
344
|
+
addr := authorityAddr(req.URL.Scheme, req.URL.Host)
|
345
|
+
for retry := 0; ; retry++ {
|
346
|
+
cc, err := t.connPool().GetClientConn(req, addr)
|
347
|
+
if err != nil {
|
348
|
+
t.vlogf("http2: Transport failed to get client conn for %s: %v", addr, err)
|
349
|
+
return nil, err
|
350
|
+
}
|
351
|
+
traceGotConn(req, cc)
|
352
|
+
res, err := cc.RoundTrip(req)
|
353
|
+
if err != nil && retry <= 6 {
|
354
|
+
afterBodyWrite := false
|
355
|
+
if e, ok := err.(afterReqBodyWriteError); ok {
|
356
|
+
err = e
|
357
|
+
afterBodyWrite = true
|
358
|
+
}
|
359
|
+
if req, err = shouldRetryRequest(req, err, afterBodyWrite); err == nil {
|
360
|
+
// After the first retry, do exponential backoff with 10% jitter.
|
361
|
+
if retry == 0 {
|
362
|
+
continue
|
363
|
+
}
|
364
|
+
backoff := float64(uint(1) << (uint(retry) - 1))
|
365
|
+
backoff += backoff * (0.1 * mathrand.Float64())
|
366
|
+
select {
|
367
|
+
case <-time.After(time.Second * time.Duration(backoff)):
|
368
|
+
continue
|
369
|
+
case <-reqContext(req).Done():
|
370
|
+
return nil, reqContext(req).Err()
|
371
|
+
}
|
372
|
+
}
|
373
|
+
}
|
374
|
+
if err != nil {
|
375
|
+
t.vlogf("RoundTrip failure: %v", err)
|
376
|
+
return nil, err
|
377
|
+
}
|
378
|
+
return res, nil
|
379
|
+
}
|
380
|
+
}
|
381
|
+
|
382
|
+
// CloseIdleConnections closes any connections which were previously
|
383
|
+
// connected from previous requests but are now sitting idle.
|
384
|
+
// It does not interrupt any connections currently in use.
|
385
|
+
func (t *Transport) CloseIdleConnections() {
|
386
|
+
if cp, ok := t.connPool().(clientConnPoolIdleCloser); ok {
|
387
|
+
cp.closeIdleConnections()
|
388
|
+
}
|
389
|
+
}
|
390
|
+
|
391
|
+
var (
|
392
|
+
errClientConnClosed = errors.New("http2: client conn is closed")
|
393
|
+
errClientConnUnusable = errors.New("http2: client conn not usable")
|
394
|
+
errClientConnGotGoAway = errors.New("http2: Transport received Server's graceful shutdown GOAWAY")
|
395
|
+
)
|
396
|
+
|
397
|
+
// afterReqBodyWriteError is a wrapper around errors returned by ClientConn.RoundTrip.
|
398
|
+
// It is used to signal that err happened after part of Request.Body was sent to the server.
|
399
|
+
type afterReqBodyWriteError struct {
|
400
|
+
err error
|
401
|
+
}
|
402
|
+
|
403
|
+
func (e afterReqBodyWriteError) Error() string {
|
404
|
+
return e.err.Error() + "; some request body already written"
|
405
|
+
}
|
406
|
+
|
407
|
+
// shouldRetryRequest is called by RoundTrip when a request fails to get
|
408
|
+
// response headers. It is always called with a non-nil error.
|
409
|
+
// It returns either a request to retry (either the same request, or a
|
410
|
+
// modified clone), or an error if the request can't be replayed.
|
411
|
+
func shouldRetryRequest(req *http.Request, err error, afterBodyWrite bool) (*http.Request, error) {
|
412
|
+
if !canRetryError(err) {
|
413
|
+
return nil, err
|
414
|
+
}
|
415
|
+
if !afterBodyWrite {
|
416
|
+
return req, nil
|
417
|
+
}
|
418
|
+
// If the Body is nil (or http.NoBody), it's safe to reuse
|
419
|
+
// this request and its Body.
|
420
|
+
if req.Body == nil || reqBodyIsNoBody(req.Body) {
|
421
|
+
return req, nil
|
422
|
+
}
|
423
|
+
// Otherwise we depend on the Request having its GetBody
|
424
|
+
// func defined.
|
425
|
+
getBody := reqGetBody(req) // Go 1.8: getBody = req.GetBody
|
426
|
+
if getBody == nil {
|
427
|
+
return nil, fmt.Errorf("http2: Transport: cannot retry err [%v] after Request.Body was written; define Request.GetBody to avoid this error", err)
|
428
|
+
}
|
429
|
+
body, err := getBody()
|
430
|
+
if err != nil {
|
431
|
+
return nil, err
|
432
|
+
}
|
433
|
+
newReq := *req
|
434
|
+
newReq.Body = body
|
435
|
+
return &newReq, nil
|
436
|
+
}
|
437
|
+
|
438
|
+
func canRetryError(err error) bool {
|
439
|
+
if err == errClientConnUnusable || err == errClientConnGotGoAway {
|
440
|
+
return true
|
441
|
+
}
|
442
|
+
if se, ok := err.(StreamError); ok {
|
443
|
+
return se.Code == ErrCodeRefusedStream
|
444
|
+
}
|
445
|
+
return false
|
446
|
+
}
|
447
|
+
|
448
|
+
func (t *Transport) dialClientConn(addr string, singleUse bool) (*ClientConn, error) {
|
449
|
+
host, _, err := net.SplitHostPort(addr)
|
450
|
+
if err != nil {
|
451
|
+
return nil, err
|
452
|
+
}
|
453
|
+
tconn, err := t.dialTLS()("tcp", addr, t.newTLSConfig(host))
|
454
|
+
if err != nil {
|
455
|
+
return nil, err
|
456
|
+
}
|
457
|
+
return t.newClientConn(tconn, singleUse)
|
458
|
+
}
|
459
|
+
|
460
|
+
func (t *Transport) newTLSConfig(host string) *tls.Config {
|
461
|
+
cfg := new(tls.Config)
|
462
|
+
if t.TLSClientConfig != nil {
|
463
|
+
*cfg = *cloneTLSConfig(t.TLSClientConfig)
|
464
|
+
}
|
465
|
+
if !strSliceContains(cfg.NextProtos, NextProtoTLS) {
|
466
|
+
cfg.NextProtos = append([]string{NextProtoTLS}, cfg.NextProtos...)
|
467
|
+
}
|
468
|
+
if cfg.ServerName == "" {
|
469
|
+
cfg.ServerName = host
|
470
|
+
}
|
471
|
+
return cfg
|
472
|
+
}
|
473
|
+
|
474
|
+
func (t *Transport) dialTLS() func(string, string, *tls.Config) (net.Conn, error) {
|
475
|
+
if t.DialTLS != nil {
|
476
|
+
return t.DialTLS
|
477
|
+
}
|
478
|
+
return t.dialTLSDefault
|
479
|
+
}
|
480
|
+
|
481
|
+
func (t *Transport) dialTLSDefault(network, addr string, cfg *tls.Config) (net.Conn, error) {
|
482
|
+
cn, err := tls.Dial(network, addr, cfg)
|
483
|
+
if err != nil {
|
484
|
+
return nil, err
|
485
|
+
}
|
486
|
+
if err := cn.Handshake(); err != nil {
|
487
|
+
return nil, err
|
488
|
+
}
|
489
|
+
if !cfg.InsecureSkipVerify {
|
490
|
+
if err := cn.VerifyHostname(cfg.ServerName); err != nil {
|
491
|
+
return nil, err
|
492
|
+
}
|
493
|
+
}
|
494
|
+
state := cn.ConnectionState()
|
495
|
+
if p := state.NegotiatedProtocol; p != NextProtoTLS {
|
496
|
+
return nil, fmt.Errorf("http2: unexpected ALPN protocol %q; want %q", p, NextProtoTLS)
|
497
|
+
}
|
498
|
+
if !state.NegotiatedProtocolIsMutual {
|
499
|
+
return nil, errors.New("http2: could not negotiate protocol mutually")
|
500
|
+
}
|
501
|
+
return cn, nil
|
502
|
+
}
|
503
|
+
|
504
|
+
// disableKeepAlives reports whether connections should be closed as
|
505
|
+
// soon as possible after handling the first request.
|
506
|
+
func (t *Transport) disableKeepAlives() bool {
|
507
|
+
return t.t1 != nil && t.t1.DisableKeepAlives
|
508
|
+
}
|
509
|
+
|
510
|
+
func (t *Transport) expectContinueTimeout() time.Duration {
|
511
|
+
if t.t1 == nil {
|
512
|
+
return 0
|
513
|
+
}
|
514
|
+
return transportExpectContinueTimeout(t.t1)
|
515
|
+
}
|
516
|
+
|
517
|
+
func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) {
|
518
|
+
return t.newClientConn(c, false)
|
519
|
+
}
|
520
|
+
|
521
|
+
func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, error) {
|
522
|
+
cc := &ClientConn{
|
523
|
+
t: t,
|
524
|
+
tconn: c,
|
525
|
+
readerDone: make(chan struct{}),
|
526
|
+
nextStreamID: 1,
|
527
|
+
maxFrameSize: 16 << 10, // spec default
|
528
|
+
initialWindowSize: 65535, // spec default
|
529
|
+
maxConcurrentStreams: 1000, // "infinite", per spec. 1000 seems good enough.
|
530
|
+
peerMaxHeaderListSize: 0xffffffffffffffff, // "infinite", per spec. Use 2^64-1 instead.
|
531
|
+
streams: make(map[uint32]*clientStream),
|
532
|
+
singleUse: singleUse,
|
533
|
+
wantSettingsAck: true,
|
534
|
+
pings: make(map[[8]byte]chan struct{}),
|
535
|
+
}
|
536
|
+
if d := t.idleConnTimeout(); d != 0 {
|
537
|
+
cc.idleTimeout = d
|
538
|
+
cc.idleTimer = time.AfterFunc(d, cc.onIdleTimeout)
|
539
|
+
}
|
540
|
+
if VerboseLogs {
|
541
|
+
t.vlogf("http2: Transport creating client conn %p to %v", cc, c.RemoteAddr())
|
542
|
+
}
|
543
|
+
|
544
|
+
cc.cond = sync.NewCond(&cc.mu)
|
545
|
+
cc.flow.add(int32(initialWindowSize))
|
546
|
+
|
547
|
+
// TODO: adjust this writer size to account for frame size +
|
548
|
+
// MTU + crypto/tls record padding.
|
549
|
+
cc.bw = bufio.NewWriter(stickyErrWriter{c, &cc.werr})
|
550
|
+
cc.br = bufio.NewReader(c)
|
551
|
+
cc.fr = NewFramer(cc.bw, cc.br)
|
552
|
+
cc.fr.ReadMetaHeaders = hpack.NewDecoder(initialHeaderTableSize, nil)
|
553
|
+
cc.fr.MaxHeaderListSize = t.maxHeaderListSize()
|
554
|
+
|
555
|
+
// TODO: SetMaxDynamicTableSize, SetMaxDynamicTableSizeLimit on
|
556
|
+
// henc in response to SETTINGS frames?
|
557
|
+
cc.henc = hpack.NewEncoder(&cc.hbuf)
|
558
|
+
|
559
|
+
if cs, ok := c.(connectionStater); ok {
|
560
|
+
state := cs.ConnectionState()
|
561
|
+
cc.tlsState = &state
|
562
|
+
}
|
563
|
+
|
564
|
+
initialSettings := []Setting{
|
565
|
+
{ID: SettingEnablePush, Val: 0},
|
566
|
+
{ID: SettingInitialWindowSize, Val: transportDefaultStreamFlow},
|
567
|
+
}
|
568
|
+
if max := t.maxHeaderListSize(); max != 0 {
|
569
|
+
initialSettings = append(initialSettings, Setting{ID: SettingMaxHeaderListSize, Val: max})
|
570
|
+
}
|
571
|
+
|
572
|
+
cc.bw.Write(clientPreface)
|
573
|
+
cc.fr.WriteSettings(initialSettings...)
|
574
|
+
cc.fr.WriteWindowUpdate(0, transportDefaultConnFlow)
|
575
|
+
cc.inflow.add(transportDefaultConnFlow + initialWindowSize)
|
576
|
+
cc.bw.Flush()
|
577
|
+
if cc.werr != nil {
|
578
|
+
return nil, cc.werr
|
579
|
+
}
|
580
|
+
|
581
|
+
go cc.readLoop()
|
582
|
+
return cc, nil
|
583
|
+
}
|
584
|
+
|
585
|
+
func (cc *ClientConn) setGoAway(f *GoAwayFrame) {
|
586
|
+
cc.mu.Lock()
|
587
|
+
defer cc.mu.Unlock()
|
588
|
+
|
589
|
+
old := cc.goAway
|
590
|
+
cc.goAway = f
|
591
|
+
|
592
|
+
// Merge the previous and current GoAway error frames.
|
593
|
+
if cc.goAwayDebug == "" {
|
594
|
+
cc.goAwayDebug = string(f.DebugData())
|
595
|
+
}
|
596
|
+
if old != nil && old.ErrCode != ErrCodeNo {
|
597
|
+
cc.goAway.ErrCode = old.ErrCode
|
598
|
+
}
|
599
|
+
last := f.LastStreamID
|
600
|
+
for streamID, cs := range cc.streams {
|
601
|
+
if streamID > last {
|
602
|
+
select {
|
603
|
+
case cs.resc <- resAndError{err: errClientConnGotGoAway}:
|
604
|
+
default:
|
605
|
+
}
|
606
|
+
}
|
607
|
+
}
|
608
|
+
}
|
609
|
+
|
610
|
+
// CanTakeNewRequest reports whether the connection can take a new request,
|
611
|
+
// meaning it has not been closed or received or sent a GOAWAY.
|
612
|
+
func (cc *ClientConn) CanTakeNewRequest() bool {
|
613
|
+
cc.mu.Lock()
|
614
|
+
defer cc.mu.Unlock()
|
615
|
+
return cc.canTakeNewRequestLocked()
|
616
|
+
}
|
617
|
+
|
618
|
+
func (cc *ClientConn) canTakeNewRequestLocked() bool {
|
619
|
+
if cc.singleUse && cc.nextStreamID > 1 {
|
620
|
+
return false
|
621
|
+
}
|
622
|
+
return cc.goAway == nil && !cc.closed &&
|
623
|
+
int64(cc.nextStreamID)+int64(cc.pendingRequests) < math.MaxInt32
|
624
|
+
}
|
625
|
+
|
626
|
+
// onIdleTimeout is called from a time.AfterFunc goroutine. It will
|
627
|
+
// only be called when we're idle, but because we're coming from a new
|
628
|
+
// goroutine, there could be a new request coming in at the same time,
|
629
|
+
// so this simply calls the synchronized closeIfIdle to shut down this
|
630
|
+
// connection. The timer could just call closeIfIdle, but this is more
|
631
|
+
// clear.
|
632
|
+
func (cc *ClientConn) onIdleTimeout() {
|
633
|
+
cc.closeIfIdle()
|
634
|
+
}
|
635
|
+
|
636
|
+
func (cc *ClientConn) closeIfIdle() {
|
637
|
+
cc.mu.Lock()
|
638
|
+
if len(cc.streams) > 0 {
|
639
|
+
cc.mu.Unlock()
|
640
|
+
return
|
641
|
+
}
|
642
|
+
cc.closed = true
|
643
|
+
nextID := cc.nextStreamID
|
644
|
+
// TODO: do clients send GOAWAY too? maybe? Just Close:
|
645
|
+
cc.mu.Unlock()
|
646
|
+
|
647
|
+
if VerboseLogs {
|
648
|
+
cc.vlogf("http2: Transport closing idle conn %p (forSingleUse=%v, maxStream=%v)", cc, cc.singleUse, nextID-2)
|
649
|
+
}
|
650
|
+
cc.tconn.Close()
|
651
|
+
}
|
652
|
+
|
653
|
+
const maxAllocFrameSize = 512 << 10
|
654
|
+
|
655
|
+
// frameBuffer returns a scratch buffer suitable for writing DATA frames.
|
656
|
+
// They're capped at the min of the peer's max frame size or 512KB
|
657
|
+
// (kinda arbitrarily), but definitely capped so we don't allocate 4GB
|
658
|
+
// bufers.
|
659
|
+
func (cc *ClientConn) frameScratchBuffer() []byte {
|
660
|
+
cc.mu.Lock()
|
661
|
+
size := cc.maxFrameSize
|
662
|
+
if size > maxAllocFrameSize {
|
663
|
+
size = maxAllocFrameSize
|
664
|
+
}
|
665
|
+
for i, buf := range cc.freeBuf {
|
666
|
+
if len(buf) >= int(size) {
|
667
|
+
cc.freeBuf[i] = nil
|
668
|
+
cc.mu.Unlock()
|
669
|
+
return buf[:size]
|
670
|
+
}
|
671
|
+
}
|
672
|
+
cc.mu.Unlock()
|
673
|
+
return make([]byte, size)
|
674
|
+
}
|
675
|
+
|
676
|
+
func (cc *ClientConn) putFrameScratchBuffer(buf []byte) {
|
677
|
+
cc.mu.Lock()
|
678
|
+
defer cc.mu.Unlock()
|
679
|
+
const maxBufs = 4 // arbitrary; 4 concurrent requests per conn? investigate.
|
680
|
+
if len(cc.freeBuf) < maxBufs {
|
681
|
+
cc.freeBuf = append(cc.freeBuf, buf)
|
682
|
+
return
|
683
|
+
}
|
684
|
+
for i, old := range cc.freeBuf {
|
685
|
+
if old == nil {
|
686
|
+
cc.freeBuf[i] = buf
|
687
|
+
return
|
688
|
+
}
|
689
|
+
}
|
690
|
+
// forget about it.
|
691
|
+
}
|
692
|
+
|
693
|
+
// errRequestCanceled is a copy of net/http's errRequestCanceled because it's not
|
694
|
+
// exported. At least they'll be DeepEqual for h1-vs-h2 comparisons tests.
|
695
|
+
var errRequestCanceled = errors.New("net/http: request canceled")
|
696
|
+
|
697
|
+
func commaSeparatedTrailers(req *http.Request) (string, error) {
|
698
|
+
keys := make([]string, 0, len(req.Trailer))
|
699
|
+
for k := range req.Trailer {
|
700
|
+
k = http.CanonicalHeaderKey(k)
|
701
|
+
switch k {
|
702
|
+
case "Transfer-Encoding", "Trailer", "Content-Length":
|
703
|
+
return "", &badStringError{"invalid Trailer key", k}
|
704
|
+
}
|
705
|
+
keys = append(keys, k)
|
706
|
+
}
|
707
|
+
if len(keys) > 0 {
|
708
|
+
sort.Strings(keys)
|
709
|
+
return strings.Join(keys, ","), nil
|
710
|
+
}
|
711
|
+
return "", nil
|
712
|
+
}
|
713
|
+
|
714
|
+
func (cc *ClientConn) responseHeaderTimeout() time.Duration {
|
715
|
+
if cc.t.t1 != nil {
|
716
|
+
return cc.t.t1.ResponseHeaderTimeout
|
717
|
+
}
|
718
|
+
// No way to do this (yet?) with just an http2.Transport. Probably
|
719
|
+
// no need. Request.Cancel this is the new way. We only need to support
|
720
|
+
// this for compatibility with the old http.Transport fields when
|
721
|
+
// we're doing transparent http2.
|
722
|
+
return 0
|
723
|
+
}
|
724
|
+
|
725
|
+
// checkConnHeaders checks whether req has any invalid connection-level headers.
|
726
|
+
// per RFC 7540 section 8.1.2.2: Connection-Specific Header Fields.
|
727
|
+
// Certain headers are special-cased as okay but not transmitted later.
|
728
|
+
func checkConnHeaders(req *http.Request) error {
|
729
|
+
if v := req.Header.Get("Upgrade"); v != "" {
|
730
|
+
return fmt.Errorf("http2: invalid Upgrade request header: %q", req.Header["Upgrade"])
|
731
|
+
}
|
732
|
+
if vv := req.Header["Transfer-Encoding"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "chunked") {
|
733
|
+
return fmt.Errorf("http2: invalid Transfer-Encoding request header: %q", vv)
|
734
|
+
}
|
735
|
+
if vv := req.Header["Connection"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "close" && vv[0] != "keep-alive") {
|
736
|
+
return fmt.Errorf("http2: invalid Connection request header: %q", vv)
|
737
|
+
}
|
738
|
+
return nil
|
739
|
+
}
|
740
|
+
|
741
|
+
// actualContentLength returns a sanitized version of
|
742
|
+
// req.ContentLength, where 0 actually means zero (not unknown) and -1
|
743
|
+
// means unknown.
|
744
|
+
func actualContentLength(req *http.Request) int64 {
|
745
|
+
if req.Body == nil || reqBodyIsNoBody(req.Body) {
|
746
|
+
return 0
|
747
|
+
}
|
748
|
+
if req.ContentLength != 0 {
|
749
|
+
return req.ContentLength
|
750
|
+
}
|
751
|
+
return -1
|
752
|
+
}
|
753
|
+
|
754
|
+
func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) {
|
755
|
+
if err := checkConnHeaders(req); err != nil {
|
756
|
+
return nil, err
|
757
|
+
}
|
758
|
+
if cc.idleTimer != nil {
|
759
|
+
cc.idleTimer.Stop()
|
760
|
+
}
|
761
|
+
|
762
|
+
trailers, err := commaSeparatedTrailers(req)
|
763
|
+
if err != nil {
|
764
|
+
return nil, err
|
765
|
+
}
|
766
|
+
hasTrailers := trailers != ""
|
767
|
+
|
768
|
+
cc.mu.Lock()
|
769
|
+
if err := cc.awaitOpenSlotForRequest(req); err != nil {
|
770
|
+
cc.mu.Unlock()
|
771
|
+
return nil, err
|
772
|
+
}
|
773
|
+
|
774
|
+
body := req.Body
|
775
|
+
contentLen := actualContentLength(req)
|
776
|
+
hasBody := contentLen != 0
|
777
|
+
|
778
|
+
// TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere?
|
779
|
+
var requestedGzip bool
|
780
|
+
if !cc.t.disableCompression() &&
|
781
|
+
req.Header.Get("Accept-Encoding") == "" &&
|
782
|
+
req.Header.Get("Range") == "" &&
|
783
|
+
req.Method != "HEAD" {
|
784
|
+
// Request gzip only, not deflate. Deflate is ambiguous and
|
785
|
+
// not as universally supported anyway.
|
786
|
+
// See: http://www.gzip.org/zlib/zlib_faq.html#faq38
|
787
|
+
//
|
788
|
+
// Note that we don't request this for HEAD requests,
|
789
|
+
// due to a bug in nginx:
|
790
|
+
// http://trac.nginx.org/nginx/ticket/358
|
791
|
+
// https://golang.org/issue/5522
|
792
|
+
//
|
793
|
+
// We don't request gzip if the request is for a range, since
|
794
|
+
// auto-decoding a portion of a gzipped document will just fail
|
795
|
+
// anyway. See https://golang.org/issue/8923
|
796
|
+
requestedGzip = true
|
797
|
+
}
|
798
|
+
|
799
|
+
// we send: HEADERS{1}, CONTINUATION{0,} + DATA{0,} (DATA is
|
800
|
+
// sent by writeRequestBody below, along with any Trailers,
|
801
|
+
// again in form HEADERS{1}, CONTINUATION{0,})
|
802
|
+
hdrs, err := cc.encodeHeaders(req, requestedGzip, trailers, contentLen)
|
803
|
+
if err != nil {
|
804
|
+
cc.mu.Unlock()
|
805
|
+
return nil, err
|
806
|
+
}
|
807
|
+
|
808
|
+
cs := cc.newStream()
|
809
|
+
cs.req = req
|
810
|
+
cs.trace = requestTrace(req)
|
811
|
+
cs.requestedGzip = requestedGzip
|
812
|
+
bodyWriter := cc.t.getBodyWriterState(cs, body)
|
813
|
+
cs.on100 = bodyWriter.on100
|
814
|
+
|
815
|
+
cc.wmu.Lock()
|
816
|
+
endStream := !hasBody && !hasTrailers
|
817
|
+
werr := cc.writeHeaders(cs.ID, endStream, hdrs)
|
818
|
+
cc.wmu.Unlock()
|
819
|
+
traceWroteHeaders(cs.trace)
|
820
|
+
cc.mu.Unlock()
|
821
|
+
|
822
|
+
if werr != nil {
|
823
|
+
if hasBody {
|
824
|
+
req.Body.Close() // per RoundTripper contract
|
825
|
+
bodyWriter.cancel()
|
826
|
+
}
|
827
|
+
cc.forgetStreamID(cs.ID)
|
828
|
+
// Don't bother sending a RST_STREAM (our write already failed;
|
829
|
+
// no need to keep writing)
|
830
|
+
traceWroteRequest(cs.trace, werr)
|
831
|
+
return nil, werr
|
832
|
+
}
|
833
|
+
|
834
|
+
var respHeaderTimer <-chan time.Time
|
835
|
+
if hasBody {
|
836
|
+
bodyWriter.scheduleBodyWrite()
|
837
|
+
} else {
|
838
|
+
traceWroteRequest(cs.trace, nil)
|
839
|
+
if d := cc.responseHeaderTimeout(); d != 0 {
|
840
|
+
timer := time.NewTimer(d)
|
841
|
+
defer timer.Stop()
|
842
|
+
respHeaderTimer = timer.C
|
843
|
+
}
|
844
|
+
}
|
845
|
+
|
846
|
+
readLoopResCh := cs.resc
|
847
|
+
bodyWritten := false
|
848
|
+
ctx := reqContext(req)
|
849
|
+
|
850
|
+
handleReadLoopResponse := func(re resAndError) (*http.Response, error) {
|
851
|
+
res := re.res
|
852
|
+
if re.err != nil || res.StatusCode > 299 {
|
853
|
+
// On error or status code 3xx, 4xx, 5xx, etc abort any
|
854
|
+
// ongoing write, assuming that the server doesn't care
|
855
|
+
// about our request body. If the server replied with 1xx or
|
856
|
+
// 2xx, however, then assume the server DOES potentially
|
857
|
+
// want our body (e.g. full-duplex streaming:
|
858
|
+
// golang.org/issue/13444). If it turns out the server
|
859
|
+
// doesn't, they'll RST_STREAM us soon enough. This is a
|
860
|
+
// heuristic to avoid adding knobs to Transport. Hopefully
|
861
|
+
// we can keep it.
|
862
|
+
bodyWriter.cancel()
|
863
|
+
cs.abortRequestBodyWrite(errStopReqBodyWrite)
|
864
|
+
}
|
865
|
+
if re.err != nil {
|
866
|
+
cc.mu.Lock()
|
867
|
+
afterBodyWrite := cs.startedWrite
|
868
|
+
cc.mu.Unlock()
|
869
|
+
cc.forgetStreamID(cs.ID)
|
870
|
+
if afterBodyWrite {
|
871
|
+
return nil, afterReqBodyWriteError{re.err}
|
872
|
+
}
|
873
|
+
return nil, re.err
|
874
|
+
}
|
875
|
+
res.Request = req
|
876
|
+
res.TLS = cc.tlsState
|
877
|
+
return res, nil
|
878
|
+
}
|
879
|
+
|
880
|
+
for {
|
881
|
+
select {
|
882
|
+
case re := <-readLoopResCh:
|
883
|
+
return handleReadLoopResponse(re)
|
884
|
+
case <-respHeaderTimer:
|
885
|
+
if !hasBody || bodyWritten {
|
886
|
+
cc.writeStreamReset(cs.ID, ErrCodeCancel, nil)
|
887
|
+
} else {
|
888
|
+
bodyWriter.cancel()
|
889
|
+
cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel)
|
890
|
+
}
|
891
|
+
cc.forgetStreamID(cs.ID)
|
892
|
+
return nil, errTimeout
|
893
|
+
case <-ctx.Done():
|
894
|
+
if !hasBody || bodyWritten {
|
895
|
+
cc.writeStreamReset(cs.ID, ErrCodeCancel, nil)
|
896
|
+
} else {
|
897
|
+
bodyWriter.cancel()
|
898
|
+
cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel)
|
899
|
+
}
|
900
|
+
cc.forgetStreamID(cs.ID)
|
901
|
+
return nil, ctx.Err()
|
902
|
+
case <-req.Cancel:
|
903
|
+
if !hasBody || bodyWritten {
|
904
|
+
cc.writeStreamReset(cs.ID, ErrCodeCancel, nil)
|
905
|
+
} else {
|
906
|
+
bodyWriter.cancel()
|
907
|
+
cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel)
|
908
|
+
}
|
909
|
+
cc.forgetStreamID(cs.ID)
|
910
|
+
return nil, errRequestCanceled
|
911
|
+
case <-cs.peerReset:
|
912
|
+
// processResetStream already removed the
|
913
|
+
// stream from the streams map; no need for
|
914
|
+
// forgetStreamID.
|
915
|
+
return nil, cs.resetErr
|
916
|
+
case err := <-bodyWriter.resc:
|
917
|
+
// Prefer the read loop's response, if available. Issue 16102.
|
918
|
+
select {
|
919
|
+
case re := <-readLoopResCh:
|
920
|
+
return handleReadLoopResponse(re)
|
921
|
+
default:
|
922
|
+
}
|
923
|
+
if err != nil {
|
924
|
+
return nil, err
|
925
|
+
}
|
926
|
+
bodyWritten = true
|
927
|
+
if d := cc.responseHeaderTimeout(); d != 0 {
|
928
|
+
timer := time.NewTimer(d)
|
929
|
+
defer timer.Stop()
|
930
|
+
respHeaderTimer = timer.C
|
931
|
+
}
|
932
|
+
}
|
933
|
+
}
|
934
|
+
}
|
935
|
+
|
936
|
+
// awaitOpenSlotForRequest waits until len(streams) < maxConcurrentStreams.
|
937
|
+
// Must hold cc.mu.
|
938
|
+
func (cc *ClientConn) awaitOpenSlotForRequest(req *http.Request) error {
|
939
|
+
var waitingForConn chan struct{}
|
940
|
+
var waitingForConnErr error // guarded by cc.mu
|
941
|
+
for {
|
942
|
+
cc.lastActive = time.Now()
|
943
|
+
if cc.closed || !cc.canTakeNewRequestLocked() {
|
944
|
+
return errClientConnUnusable
|
945
|
+
}
|
946
|
+
if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) {
|
947
|
+
if waitingForConn != nil {
|
948
|
+
close(waitingForConn)
|
949
|
+
}
|
950
|
+
return nil
|
951
|
+
}
|
952
|
+
// Unfortunately, we cannot wait on a condition variable and channel at
|
953
|
+
// the same time, so instead, we spin up a goroutine to check if the
|
954
|
+
// request is canceled while we wait for a slot to open in the connection.
|
955
|
+
if waitingForConn == nil {
|
956
|
+
waitingForConn = make(chan struct{})
|
957
|
+
go func() {
|
958
|
+
if err := awaitRequestCancel(req, waitingForConn); err != nil {
|
959
|
+
cc.mu.Lock()
|
960
|
+
waitingForConnErr = err
|
961
|
+
cc.cond.Broadcast()
|
962
|
+
cc.mu.Unlock()
|
963
|
+
}
|
964
|
+
}()
|
965
|
+
}
|
966
|
+
cc.pendingRequests++
|
967
|
+
cc.cond.Wait()
|
968
|
+
cc.pendingRequests--
|
969
|
+
if waitingForConnErr != nil {
|
970
|
+
return waitingForConnErr
|
971
|
+
}
|
972
|
+
}
|
973
|
+
}
|
974
|
+
|
975
|
+
// requires cc.wmu be held
|
976
|
+
func (cc *ClientConn) writeHeaders(streamID uint32, endStream bool, hdrs []byte) error {
|
977
|
+
first := true // first frame written (HEADERS is first, then CONTINUATION)
|
978
|
+
frameSize := int(cc.maxFrameSize)
|
979
|
+
for len(hdrs) > 0 && cc.werr == nil {
|
980
|
+
chunk := hdrs
|
981
|
+
if len(chunk) > frameSize {
|
982
|
+
chunk = chunk[:frameSize]
|
983
|
+
}
|
984
|
+
hdrs = hdrs[len(chunk):]
|
985
|
+
endHeaders := len(hdrs) == 0
|
986
|
+
if first {
|
987
|
+
cc.fr.WriteHeaders(HeadersFrameParam{
|
988
|
+
StreamID: streamID,
|
989
|
+
BlockFragment: chunk,
|
990
|
+
EndStream: endStream,
|
991
|
+
EndHeaders: endHeaders,
|
992
|
+
})
|
993
|
+
first = false
|
994
|
+
} else {
|
995
|
+
cc.fr.WriteContinuation(streamID, endHeaders, chunk)
|
996
|
+
}
|
997
|
+
}
|
998
|
+
// TODO(bradfitz): this Flush could potentially block (as
|
999
|
+
// could the WriteHeaders call(s) above), which means they
|
1000
|
+
// wouldn't respond to Request.Cancel being readable. That's
|
1001
|
+
// rare, but this should probably be in a goroutine.
|
1002
|
+
cc.bw.Flush()
|
1003
|
+
return cc.werr
|
1004
|
+
}
|
1005
|
+
|
1006
|
+
// internal error values; they don't escape to callers
|
1007
|
+
var (
|
1008
|
+
// abort request body write; don't send cancel
|
1009
|
+
errStopReqBodyWrite = errors.New("http2: aborting request body write")
|
1010
|
+
|
1011
|
+
// abort request body write, but send stream reset of cancel.
|
1012
|
+
errStopReqBodyWriteAndCancel = errors.New("http2: canceling request")
|
1013
|
+
)
|
1014
|
+
|
1015
|
+
func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) (err error) {
|
1016
|
+
cc := cs.cc
|
1017
|
+
sentEnd := false // whether we sent the final DATA frame w/ END_STREAM
|
1018
|
+
buf := cc.frameScratchBuffer()
|
1019
|
+
defer cc.putFrameScratchBuffer(buf)
|
1020
|
+
|
1021
|
+
defer func() {
|
1022
|
+
traceWroteRequest(cs.trace, err)
|
1023
|
+
// TODO: write h12Compare test showing whether
|
1024
|
+
// Request.Body is closed by the Transport,
|
1025
|
+
// and in multiple cases: server replies <=299 and >299
|
1026
|
+
// while still writing request body
|
1027
|
+
cerr := bodyCloser.Close()
|
1028
|
+
if err == nil {
|
1029
|
+
err = cerr
|
1030
|
+
}
|
1031
|
+
}()
|
1032
|
+
|
1033
|
+
req := cs.req
|
1034
|
+
hasTrailers := req.Trailer != nil
|
1035
|
+
|
1036
|
+
var sawEOF bool
|
1037
|
+
for !sawEOF {
|
1038
|
+
n, err := body.Read(buf)
|
1039
|
+
if err == io.EOF {
|
1040
|
+
sawEOF = true
|
1041
|
+
err = nil
|
1042
|
+
} else if err != nil {
|
1043
|
+
return err
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
remain := buf[:n]
|
1047
|
+
for len(remain) > 0 && err == nil {
|
1048
|
+
var allowed int32
|
1049
|
+
allowed, err = cs.awaitFlowControl(len(remain))
|
1050
|
+
switch {
|
1051
|
+
case err == errStopReqBodyWrite:
|
1052
|
+
return err
|
1053
|
+
case err == errStopReqBodyWriteAndCancel:
|
1054
|
+
cc.writeStreamReset(cs.ID, ErrCodeCancel, nil)
|
1055
|
+
return err
|
1056
|
+
case err != nil:
|
1057
|
+
return err
|
1058
|
+
}
|
1059
|
+
cc.wmu.Lock()
|
1060
|
+
data := remain[:allowed]
|
1061
|
+
remain = remain[allowed:]
|
1062
|
+
sentEnd = sawEOF && len(remain) == 0 && !hasTrailers
|
1063
|
+
err = cc.fr.WriteData(cs.ID, sentEnd, data)
|
1064
|
+
if err == nil {
|
1065
|
+
// TODO(bradfitz): this flush is for latency, not bandwidth.
|
1066
|
+
// Most requests won't need this. Make this opt-in or
|
1067
|
+
// opt-out? Use some heuristic on the body type? Nagel-like
|
1068
|
+
// timers? Based on 'n'? Only last chunk of this for loop,
|
1069
|
+
// unless flow control tokens are low? For now, always.
|
1070
|
+
// If we change this, see comment below.
|
1071
|
+
err = cc.bw.Flush()
|
1072
|
+
}
|
1073
|
+
cc.wmu.Unlock()
|
1074
|
+
}
|
1075
|
+
if err != nil {
|
1076
|
+
return err
|
1077
|
+
}
|
1078
|
+
}
|
1079
|
+
|
1080
|
+
if sentEnd {
|
1081
|
+
// Already sent END_STREAM (which implies we have no
|
1082
|
+
// trailers) and flushed, because currently all
|
1083
|
+
// WriteData frames above get a flush. So we're done.
|
1084
|
+
return nil
|
1085
|
+
}
|
1086
|
+
|
1087
|
+
var trls []byte
|
1088
|
+
if hasTrailers {
|
1089
|
+
cc.mu.Lock()
|
1090
|
+
trls, err = cc.encodeTrailers(req)
|
1091
|
+
cc.mu.Unlock()
|
1092
|
+
if err != nil {
|
1093
|
+
cc.writeStreamReset(cs.ID, ErrCodeInternal, err)
|
1094
|
+
cc.forgetStreamID(cs.ID)
|
1095
|
+
return err
|
1096
|
+
}
|
1097
|
+
}
|
1098
|
+
|
1099
|
+
cc.wmu.Lock()
|
1100
|
+
defer cc.wmu.Unlock()
|
1101
|
+
|
1102
|
+
// Two ways to send END_STREAM: either with trailers, or
|
1103
|
+
// with an empty DATA frame.
|
1104
|
+
if len(trls) > 0 {
|
1105
|
+
err = cc.writeHeaders(cs.ID, true, trls)
|
1106
|
+
} else {
|
1107
|
+
err = cc.fr.WriteData(cs.ID, true, nil)
|
1108
|
+
}
|
1109
|
+
if ferr := cc.bw.Flush(); ferr != nil && err == nil {
|
1110
|
+
err = ferr
|
1111
|
+
}
|
1112
|
+
return err
|
1113
|
+
}
|
1114
|
+
|
1115
|
+
// awaitFlowControl waits for [1, min(maxBytes, cc.cs.maxFrameSize)] flow
|
1116
|
+
// control tokens from the server.
|
1117
|
+
// It returns either the non-zero number of tokens taken or an error
|
1118
|
+
// if the stream is dead.
|
1119
|
+
func (cs *clientStream) awaitFlowControl(maxBytes int) (taken int32, err error) {
|
1120
|
+
cc := cs.cc
|
1121
|
+
cc.mu.Lock()
|
1122
|
+
defer cc.mu.Unlock()
|
1123
|
+
for {
|
1124
|
+
if cc.closed {
|
1125
|
+
return 0, errClientConnClosed
|
1126
|
+
}
|
1127
|
+
if cs.stopReqBody != nil {
|
1128
|
+
return 0, cs.stopReqBody
|
1129
|
+
}
|
1130
|
+
if err := cs.checkResetOrDone(); err != nil {
|
1131
|
+
return 0, err
|
1132
|
+
}
|
1133
|
+
if a := cs.flow.available(); a > 0 {
|
1134
|
+
take := a
|
1135
|
+
if int(take) > maxBytes {
|
1136
|
+
|
1137
|
+
take = int32(maxBytes) // can't truncate int; take is int32
|
1138
|
+
}
|
1139
|
+
if take > int32(cc.maxFrameSize) {
|
1140
|
+
take = int32(cc.maxFrameSize)
|
1141
|
+
}
|
1142
|
+
cs.flow.take(take)
|
1143
|
+
return take, nil
|
1144
|
+
}
|
1145
|
+
cc.cond.Wait()
|
1146
|
+
}
|
1147
|
+
}
|
1148
|
+
|
1149
|
+
type badStringError struct {
|
1150
|
+
what string
|
1151
|
+
str string
|
1152
|
+
}
|
1153
|
+
|
1154
|
+
func (e *badStringError) Error() string { return fmt.Sprintf("%s %q", e.what, e.str) }
|
1155
|
+
|
1156
|
+
// requires cc.mu be held.
|
1157
|
+
func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trailers string, contentLength int64) ([]byte, error) {
|
1158
|
+
cc.hbuf.Reset()
|
1159
|
+
|
1160
|
+
host := req.Host
|
1161
|
+
if host == "" {
|
1162
|
+
host = req.URL.Host
|
1163
|
+
}
|
1164
|
+
host, err := httplex.PunycodeHostPort(host)
|
1165
|
+
if err != nil {
|
1166
|
+
return nil, err
|
1167
|
+
}
|
1168
|
+
|
1169
|
+
var path string
|
1170
|
+
if req.Method != "CONNECT" {
|
1171
|
+
path = req.URL.RequestURI()
|
1172
|
+
if !validPseudoPath(path) {
|
1173
|
+
orig := path
|
1174
|
+
path = strings.TrimPrefix(path, req.URL.Scheme+"://"+host)
|
1175
|
+
if !validPseudoPath(path) {
|
1176
|
+
if req.URL.Opaque != "" {
|
1177
|
+
return nil, fmt.Errorf("invalid request :path %q from URL.Opaque = %q", orig, req.URL.Opaque)
|
1178
|
+
} else {
|
1179
|
+
return nil, fmt.Errorf("invalid request :path %q", orig)
|
1180
|
+
}
|
1181
|
+
}
|
1182
|
+
}
|
1183
|
+
}
|
1184
|
+
|
1185
|
+
// Check for any invalid headers and return an error before we
|
1186
|
+
// potentially pollute our hpack state. (We want to be able to
|
1187
|
+
// continue to reuse the hpack encoder for future requests)
|
1188
|
+
for k, vv := range req.Header {
|
1189
|
+
if !httplex.ValidHeaderFieldName(k) {
|
1190
|
+
return nil, fmt.Errorf("invalid HTTP header name %q", k)
|
1191
|
+
}
|
1192
|
+
for _, v := range vv {
|
1193
|
+
if !httplex.ValidHeaderFieldValue(v) {
|
1194
|
+
return nil, fmt.Errorf("invalid HTTP header value %q for header %q", v, k)
|
1195
|
+
}
|
1196
|
+
}
|
1197
|
+
}
|
1198
|
+
|
1199
|
+
enumerateHeaders := func(f func(name, value string)) {
|
1200
|
+
// 8.1.2.3 Request Pseudo-Header Fields
|
1201
|
+
// The :path pseudo-header field includes the path and query parts of the
|
1202
|
+
// target URI (the path-absolute production and optionally a '?' character
|
1203
|
+
// followed by the query production (see Sections 3.3 and 3.4 of
|
1204
|
+
// [RFC3986]).
|
1205
|
+
f(":authority", host)
|
1206
|
+
f(":method", req.Method)
|
1207
|
+
if req.Method != "CONNECT" {
|
1208
|
+
f(":path", path)
|
1209
|
+
f(":scheme", req.URL.Scheme)
|
1210
|
+
}
|
1211
|
+
if trailers != "" {
|
1212
|
+
f("trailer", trailers)
|
1213
|
+
}
|
1214
|
+
|
1215
|
+
var didUA bool
|
1216
|
+
for k, vv := range req.Header {
|
1217
|
+
if strings.EqualFold(k, "host") || strings.EqualFold(k, "content-length") {
|
1218
|
+
// Host is :authority, already sent.
|
1219
|
+
// Content-Length is automatic, set below.
|
1220
|
+
continue
|
1221
|
+
} else if strings.EqualFold(k, "connection") || strings.EqualFold(k, "proxy-connection") ||
|
1222
|
+
strings.EqualFold(k, "transfer-encoding") || strings.EqualFold(k, "upgrade") ||
|
1223
|
+
strings.EqualFold(k, "keep-alive") {
|
1224
|
+
// Per 8.1.2.2 Connection-Specific Header
|
1225
|
+
// Fields, don't send connection-specific
|
1226
|
+
// fields. We have already checked if any
|
1227
|
+
// are error-worthy so just ignore the rest.
|
1228
|
+
continue
|
1229
|
+
} else if strings.EqualFold(k, "user-agent") {
|
1230
|
+
// Match Go's http1 behavior: at most one
|
1231
|
+
// User-Agent. If set to nil or empty string,
|
1232
|
+
// then omit it. Otherwise if not mentioned,
|
1233
|
+
// include the default (below).
|
1234
|
+
didUA = true
|
1235
|
+
if len(vv) < 1 {
|
1236
|
+
continue
|
1237
|
+
}
|
1238
|
+
vv = vv[:1]
|
1239
|
+
if vv[0] == "" {
|
1240
|
+
continue
|
1241
|
+
}
|
1242
|
+
|
1243
|
+
}
|
1244
|
+
|
1245
|
+
for _, v := range vv {
|
1246
|
+
f(k, v)
|
1247
|
+
}
|
1248
|
+
}
|
1249
|
+
if shouldSendReqContentLength(req.Method, contentLength) {
|
1250
|
+
f("content-length", strconv.FormatInt(contentLength, 10))
|
1251
|
+
}
|
1252
|
+
if addGzipHeader {
|
1253
|
+
f("accept-encoding", "gzip")
|
1254
|
+
}
|
1255
|
+
if !didUA {
|
1256
|
+
f("user-agent", defaultUserAgent)
|
1257
|
+
}
|
1258
|
+
}
|
1259
|
+
|
1260
|
+
// Do a first pass over the headers counting bytes to ensure
|
1261
|
+
// we don't exceed cc.peerMaxHeaderListSize. This is done as a
|
1262
|
+
// separate pass before encoding the headers to prevent
|
1263
|
+
// modifying the hpack state.
|
1264
|
+
hlSize := uint64(0)
|
1265
|
+
enumerateHeaders(func(name, value string) {
|
1266
|
+
hf := hpack.HeaderField{Name: name, Value: value}
|
1267
|
+
hlSize += uint64(hf.Size())
|
1268
|
+
})
|
1269
|
+
|
1270
|
+
if hlSize > cc.peerMaxHeaderListSize {
|
1271
|
+
return nil, errRequestHeaderListSize
|
1272
|
+
}
|
1273
|
+
|
1274
|
+
// Header list size is ok. Write the headers.
|
1275
|
+
enumerateHeaders(func(name, value string) {
|
1276
|
+
cc.writeHeader(strings.ToLower(name), value)
|
1277
|
+
})
|
1278
|
+
|
1279
|
+
return cc.hbuf.Bytes(), nil
|
1280
|
+
}
|
1281
|
+
|
1282
|
+
// shouldSendReqContentLength reports whether the http2.Transport should send
|
1283
|
+
// a "content-length" request header. This logic is basically a copy of the net/http
|
1284
|
+
// transferWriter.shouldSendContentLength.
|
1285
|
+
// The contentLength is the corrected contentLength (so 0 means actually 0, not unknown).
|
1286
|
+
// -1 means unknown.
|
1287
|
+
func shouldSendReqContentLength(method string, contentLength int64) bool {
|
1288
|
+
if contentLength > 0 {
|
1289
|
+
return true
|
1290
|
+
}
|
1291
|
+
if contentLength < 0 {
|
1292
|
+
return false
|
1293
|
+
}
|
1294
|
+
// For zero bodies, whether we send a content-length depends on the method.
|
1295
|
+
// It also kinda doesn't matter for http2 either way, with END_STREAM.
|
1296
|
+
switch method {
|
1297
|
+
case "POST", "PUT", "PATCH":
|
1298
|
+
return true
|
1299
|
+
default:
|
1300
|
+
return false
|
1301
|
+
}
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
// requires cc.mu be held.
|
1305
|
+
func (cc *ClientConn) encodeTrailers(req *http.Request) ([]byte, error) {
|
1306
|
+
cc.hbuf.Reset()
|
1307
|
+
|
1308
|
+
hlSize := uint64(0)
|
1309
|
+
for k, vv := range req.Trailer {
|
1310
|
+
for _, v := range vv {
|
1311
|
+
hf := hpack.HeaderField{Name: k, Value: v}
|
1312
|
+
hlSize += uint64(hf.Size())
|
1313
|
+
}
|
1314
|
+
}
|
1315
|
+
if hlSize > cc.peerMaxHeaderListSize {
|
1316
|
+
return nil, errRequestHeaderListSize
|
1317
|
+
}
|
1318
|
+
|
1319
|
+
for k, vv := range req.Trailer {
|
1320
|
+
// Transfer-Encoding, etc.. have already been filtered at the
|
1321
|
+
// start of RoundTrip
|
1322
|
+
lowKey := strings.ToLower(k)
|
1323
|
+
for _, v := range vv {
|
1324
|
+
cc.writeHeader(lowKey, v)
|
1325
|
+
}
|
1326
|
+
}
|
1327
|
+
return cc.hbuf.Bytes(), nil
|
1328
|
+
}
|
1329
|
+
|
1330
|
+
func (cc *ClientConn) writeHeader(name, value string) {
|
1331
|
+
if VerboseLogs {
|
1332
|
+
log.Printf("http2: Transport encoding header %q = %q", name, value)
|
1333
|
+
}
|
1334
|
+
cc.henc.WriteField(hpack.HeaderField{Name: name, Value: value})
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
type resAndError struct {
|
1338
|
+
res *http.Response
|
1339
|
+
err error
|
1340
|
+
}
|
1341
|
+
|
1342
|
+
// requires cc.mu be held.
|
1343
|
+
func (cc *ClientConn) newStream() *clientStream {
|
1344
|
+
cs := &clientStream{
|
1345
|
+
cc: cc,
|
1346
|
+
ID: cc.nextStreamID,
|
1347
|
+
resc: make(chan resAndError, 1),
|
1348
|
+
peerReset: make(chan struct{}),
|
1349
|
+
done: make(chan struct{}),
|
1350
|
+
}
|
1351
|
+
cs.flow.add(int32(cc.initialWindowSize))
|
1352
|
+
cs.flow.setConnFlow(&cc.flow)
|
1353
|
+
cs.inflow.add(transportDefaultStreamFlow)
|
1354
|
+
cs.inflow.setConnFlow(&cc.inflow)
|
1355
|
+
cc.nextStreamID += 2
|
1356
|
+
cc.streams[cs.ID] = cs
|
1357
|
+
return cs
|
1358
|
+
}
|
1359
|
+
|
1360
|
+
func (cc *ClientConn) forgetStreamID(id uint32) {
|
1361
|
+
cc.streamByID(id, true)
|
1362
|
+
}
|
1363
|
+
|
1364
|
+
func (cc *ClientConn) streamByID(id uint32, andRemove bool) *clientStream {
|
1365
|
+
cc.mu.Lock()
|
1366
|
+
defer cc.mu.Unlock()
|
1367
|
+
cs := cc.streams[id]
|
1368
|
+
if andRemove && cs != nil && !cc.closed {
|
1369
|
+
cc.lastActive = time.Now()
|
1370
|
+
delete(cc.streams, id)
|
1371
|
+
if len(cc.streams) == 0 && cc.idleTimer != nil {
|
1372
|
+
cc.idleTimer.Reset(cc.idleTimeout)
|
1373
|
+
}
|
1374
|
+
close(cs.done)
|
1375
|
+
// Wake up checkResetOrDone via clientStream.awaitFlowControl and
|
1376
|
+
// wake up RoundTrip if there is a pending request.
|
1377
|
+
cc.cond.Broadcast()
|
1378
|
+
}
|
1379
|
+
return cs
|
1380
|
+
}
|
1381
|
+
|
1382
|
+
// clientConnReadLoop is the state owned by the clientConn's frame-reading readLoop.
|
1383
|
+
type clientConnReadLoop struct {
|
1384
|
+
cc *ClientConn
|
1385
|
+
activeRes map[uint32]*clientStream // keyed by streamID
|
1386
|
+
closeWhenIdle bool
|
1387
|
+
}
|
1388
|
+
|
1389
|
+
// readLoop runs in its own goroutine and reads and dispatches frames.
|
1390
|
+
func (cc *ClientConn) readLoop() {
|
1391
|
+
rl := &clientConnReadLoop{
|
1392
|
+
cc: cc,
|
1393
|
+
activeRes: make(map[uint32]*clientStream),
|
1394
|
+
}
|
1395
|
+
|
1396
|
+
defer rl.cleanup()
|
1397
|
+
cc.readerErr = rl.run()
|
1398
|
+
if ce, ok := cc.readerErr.(ConnectionError); ok {
|
1399
|
+
cc.wmu.Lock()
|
1400
|
+
cc.fr.WriteGoAway(0, ErrCode(ce), nil)
|
1401
|
+
cc.wmu.Unlock()
|
1402
|
+
}
|
1403
|
+
}
|
1404
|
+
|
1405
|
+
// GoAwayError is returned by the Transport when the server closes the
|
1406
|
+
// TCP connection after sending a GOAWAY frame.
|
1407
|
+
type GoAwayError struct {
|
1408
|
+
LastStreamID uint32
|
1409
|
+
ErrCode ErrCode
|
1410
|
+
DebugData string
|
1411
|
+
}
|
1412
|
+
|
1413
|
+
func (e GoAwayError) Error() string {
|
1414
|
+
return fmt.Sprintf("http2: server sent GOAWAY and closed the connection; LastStreamID=%v, ErrCode=%v, debug=%q",
|
1415
|
+
e.LastStreamID, e.ErrCode, e.DebugData)
|
1416
|
+
}
|
1417
|
+
|
1418
|
+
func isEOFOrNetReadError(err error) bool {
|
1419
|
+
if err == io.EOF {
|
1420
|
+
return true
|
1421
|
+
}
|
1422
|
+
ne, ok := err.(*net.OpError)
|
1423
|
+
return ok && ne.Op == "read"
|
1424
|
+
}
|
1425
|
+
|
1426
|
+
func (rl *clientConnReadLoop) cleanup() {
|
1427
|
+
cc := rl.cc
|
1428
|
+
defer cc.tconn.Close()
|
1429
|
+
defer cc.t.connPool().MarkDead(cc)
|
1430
|
+
defer close(cc.readerDone)
|
1431
|
+
|
1432
|
+
if cc.idleTimer != nil {
|
1433
|
+
cc.idleTimer.Stop()
|
1434
|
+
}
|
1435
|
+
|
1436
|
+
// Close any response bodies if the server closes prematurely.
|
1437
|
+
// TODO: also do this if we've written the headers but not
|
1438
|
+
// gotten a response yet.
|
1439
|
+
err := cc.readerErr
|
1440
|
+
cc.mu.Lock()
|
1441
|
+
if cc.goAway != nil && isEOFOrNetReadError(err) {
|
1442
|
+
err = GoAwayError{
|
1443
|
+
LastStreamID: cc.goAway.LastStreamID,
|
1444
|
+
ErrCode: cc.goAway.ErrCode,
|
1445
|
+
DebugData: cc.goAwayDebug,
|
1446
|
+
}
|
1447
|
+
} else if err == io.EOF {
|
1448
|
+
err = io.ErrUnexpectedEOF
|
1449
|
+
}
|
1450
|
+
for _, cs := range rl.activeRes {
|
1451
|
+
cs.bufPipe.CloseWithError(err)
|
1452
|
+
}
|
1453
|
+
for _, cs := range cc.streams {
|
1454
|
+
select {
|
1455
|
+
case cs.resc <- resAndError{err: err}:
|
1456
|
+
default:
|
1457
|
+
}
|
1458
|
+
close(cs.done)
|
1459
|
+
}
|
1460
|
+
cc.closed = true
|
1461
|
+
cc.cond.Broadcast()
|
1462
|
+
cc.mu.Unlock()
|
1463
|
+
}
|
1464
|
+
|
1465
|
+
func (rl *clientConnReadLoop) run() error {
|
1466
|
+
cc := rl.cc
|
1467
|
+
rl.closeWhenIdle = cc.t.disableKeepAlives() || cc.singleUse
|
1468
|
+
gotReply := false // ever saw a HEADERS reply
|
1469
|
+
gotSettings := false
|
1470
|
+
for {
|
1471
|
+
f, err := cc.fr.ReadFrame()
|
1472
|
+
if err != nil {
|
1473
|
+
cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err)
|
1474
|
+
}
|
1475
|
+
if se, ok := err.(StreamError); ok {
|
1476
|
+
if cs := cc.streamByID(se.StreamID, false); cs != nil {
|
1477
|
+
cs.cc.writeStreamReset(cs.ID, se.Code, err)
|
1478
|
+
cs.cc.forgetStreamID(cs.ID)
|
1479
|
+
if se.Cause == nil {
|
1480
|
+
se.Cause = cc.fr.errDetail
|
1481
|
+
}
|
1482
|
+
rl.endStreamError(cs, se)
|
1483
|
+
}
|
1484
|
+
continue
|
1485
|
+
} else if err != nil {
|
1486
|
+
return err
|
1487
|
+
}
|
1488
|
+
if VerboseLogs {
|
1489
|
+
cc.vlogf("http2: Transport received %s", summarizeFrame(f))
|
1490
|
+
}
|
1491
|
+
if !gotSettings {
|
1492
|
+
if _, ok := f.(*SettingsFrame); !ok {
|
1493
|
+
cc.logf("protocol error: received %T before a SETTINGS frame", f)
|
1494
|
+
return ConnectionError(ErrCodeProtocol)
|
1495
|
+
}
|
1496
|
+
gotSettings = true
|
1497
|
+
}
|
1498
|
+
maybeIdle := false // whether frame might transition us to idle
|
1499
|
+
|
1500
|
+
switch f := f.(type) {
|
1501
|
+
case *MetaHeadersFrame:
|
1502
|
+
err = rl.processHeaders(f)
|
1503
|
+
maybeIdle = true
|
1504
|
+
gotReply = true
|
1505
|
+
case *DataFrame:
|
1506
|
+
err = rl.processData(f)
|
1507
|
+
maybeIdle = true
|
1508
|
+
case *GoAwayFrame:
|
1509
|
+
err = rl.processGoAway(f)
|
1510
|
+
maybeIdle = true
|
1511
|
+
case *RSTStreamFrame:
|
1512
|
+
err = rl.processResetStream(f)
|
1513
|
+
maybeIdle = true
|
1514
|
+
case *SettingsFrame:
|
1515
|
+
err = rl.processSettings(f)
|
1516
|
+
case *PushPromiseFrame:
|
1517
|
+
err = rl.processPushPromise(f)
|
1518
|
+
case *WindowUpdateFrame:
|
1519
|
+
err = rl.processWindowUpdate(f)
|
1520
|
+
case *PingFrame:
|
1521
|
+
err = rl.processPing(f)
|
1522
|
+
default:
|
1523
|
+
cc.logf("Transport: unhandled response frame type %T", f)
|
1524
|
+
}
|
1525
|
+
if err != nil {
|
1526
|
+
if VerboseLogs {
|
1527
|
+
cc.vlogf("http2: Transport conn %p received error from processing frame %v: %v", cc, summarizeFrame(f), err)
|
1528
|
+
}
|
1529
|
+
return err
|
1530
|
+
}
|
1531
|
+
if rl.closeWhenIdle && gotReply && maybeIdle && len(rl.activeRes) == 0 {
|
1532
|
+
cc.closeIfIdle()
|
1533
|
+
}
|
1534
|
+
}
|
1535
|
+
}
|
1536
|
+
|
1537
|
+
func (rl *clientConnReadLoop) processHeaders(f *MetaHeadersFrame) error {
|
1538
|
+
cc := rl.cc
|
1539
|
+
if f.StreamEnded() {
|
1540
|
+
// Issue 20521: If the stream has ended, streamByID() causes
|
1541
|
+
// clientStream.done to be closed, which causes the request's bodyWriter
|
1542
|
+
// to be closed with an errStreamClosed, which may be received by
|
1543
|
+
// clientConn.RoundTrip before the result of processing these headers.
|
1544
|
+
// Deferring stream closure allows the header processing to occur first.
|
1545
|
+
// clientConn.RoundTrip may still receive the bodyWriter error first, but
|
1546
|
+
// the fix for issue 16102 prioritises any response.
|
1547
|
+
defer cc.streamByID(f.StreamID, true)
|
1548
|
+
}
|
1549
|
+
cs := cc.streamByID(f.StreamID, false)
|
1550
|
+
if cs == nil {
|
1551
|
+
// We'd get here if we canceled a request while the
|
1552
|
+
// server had its response still in flight. So if this
|
1553
|
+
// was just something we canceled, ignore it.
|
1554
|
+
return nil
|
1555
|
+
}
|
1556
|
+
if !cs.firstByte {
|
1557
|
+
if cs.trace != nil {
|
1558
|
+
// TODO(bradfitz): move first response byte earlier,
|
1559
|
+
// when we first read the 9 byte header, not waiting
|
1560
|
+
// until all the HEADERS+CONTINUATION frames have been
|
1561
|
+
// merged. This works for now.
|
1562
|
+
traceFirstResponseByte(cs.trace)
|
1563
|
+
}
|
1564
|
+
cs.firstByte = true
|
1565
|
+
}
|
1566
|
+
if !cs.pastHeaders {
|
1567
|
+
cs.pastHeaders = true
|
1568
|
+
} else {
|
1569
|
+
return rl.processTrailers(cs, f)
|
1570
|
+
}
|
1571
|
+
|
1572
|
+
res, err := rl.handleResponse(cs, f)
|
1573
|
+
if err != nil {
|
1574
|
+
if _, ok := err.(ConnectionError); ok {
|
1575
|
+
return err
|
1576
|
+
}
|
1577
|
+
// Any other error type is a stream error.
|
1578
|
+
cs.cc.writeStreamReset(f.StreamID, ErrCodeProtocol, err)
|
1579
|
+
cs.resc <- resAndError{err: err}
|
1580
|
+
return nil // return nil from process* funcs to keep conn alive
|
1581
|
+
}
|
1582
|
+
if res == nil {
|
1583
|
+
// (nil, nil) special case. See handleResponse docs.
|
1584
|
+
return nil
|
1585
|
+
}
|
1586
|
+
if res.Body != noBody {
|
1587
|
+
rl.activeRes[cs.ID] = cs
|
1588
|
+
}
|
1589
|
+
cs.resTrailer = &res.Trailer
|
1590
|
+
cs.resc <- resAndError{res: res}
|
1591
|
+
return nil
|
1592
|
+
}
|
1593
|
+
|
1594
|
+
// may return error types nil, or ConnectionError. Any other error value
|
1595
|
+
// is a StreamError of type ErrCodeProtocol. The returned error in that case
|
1596
|
+
// is the detail.
|
1597
|
+
//
|
1598
|
+
// As a special case, handleResponse may return (nil, nil) to skip the
|
1599
|
+
// frame (currently only used for 100 expect continue). This special
|
1600
|
+
// case is going away after Issue 13851 is fixed.
|
1601
|
+
func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFrame) (*http.Response, error) {
|
1602
|
+
if f.Truncated {
|
1603
|
+
return nil, errResponseHeaderListSize
|
1604
|
+
}
|
1605
|
+
|
1606
|
+
status := f.PseudoValue("status")
|
1607
|
+
if status == "" {
|
1608
|
+
return nil, errors.New("missing status pseudo header")
|
1609
|
+
}
|
1610
|
+
statusCode, err := strconv.Atoi(status)
|
1611
|
+
if err != nil {
|
1612
|
+
return nil, errors.New("malformed non-numeric status pseudo header")
|
1613
|
+
}
|
1614
|
+
|
1615
|
+
if statusCode == 100 {
|
1616
|
+
traceGot100Continue(cs.trace)
|
1617
|
+
if cs.on100 != nil {
|
1618
|
+
cs.on100() // forces any write delay timer to fire
|
1619
|
+
}
|
1620
|
+
cs.pastHeaders = false // do it all again
|
1621
|
+
return nil, nil
|
1622
|
+
}
|
1623
|
+
|
1624
|
+
header := make(http.Header)
|
1625
|
+
res := &http.Response{
|
1626
|
+
Proto: "HTTP/2.0",
|
1627
|
+
ProtoMajor: 2,
|
1628
|
+
Header: header,
|
1629
|
+
StatusCode: statusCode,
|
1630
|
+
Status: status + " " + http.StatusText(statusCode),
|
1631
|
+
}
|
1632
|
+
for _, hf := range f.RegularFields() {
|
1633
|
+
key := http.CanonicalHeaderKey(hf.Name)
|
1634
|
+
if key == "Trailer" {
|
1635
|
+
t := res.Trailer
|
1636
|
+
if t == nil {
|
1637
|
+
t = make(http.Header)
|
1638
|
+
res.Trailer = t
|
1639
|
+
}
|
1640
|
+
foreachHeaderElement(hf.Value, func(v string) {
|
1641
|
+
t[http.CanonicalHeaderKey(v)] = nil
|
1642
|
+
})
|
1643
|
+
} else {
|
1644
|
+
header[key] = append(header[key], hf.Value)
|
1645
|
+
}
|
1646
|
+
}
|
1647
|
+
|
1648
|
+
streamEnded := f.StreamEnded()
|
1649
|
+
isHead := cs.req.Method == "HEAD"
|
1650
|
+
if !streamEnded || isHead {
|
1651
|
+
res.ContentLength = -1
|
1652
|
+
if clens := res.Header["Content-Length"]; len(clens) == 1 {
|
1653
|
+
if clen64, err := strconv.ParseInt(clens[0], 10, 64); err == nil {
|
1654
|
+
res.ContentLength = clen64
|
1655
|
+
} else {
|
1656
|
+
// TODO: care? unlike http/1, it won't mess up our framing, so it's
|
1657
|
+
// more safe smuggling-wise to ignore.
|
1658
|
+
}
|
1659
|
+
} else if len(clens) > 1 {
|
1660
|
+
// TODO: care? unlike http/1, it won't mess up our framing, so it's
|
1661
|
+
// more safe smuggling-wise to ignore.
|
1662
|
+
}
|
1663
|
+
}
|
1664
|
+
|
1665
|
+
if streamEnded || isHead {
|
1666
|
+
res.Body = noBody
|
1667
|
+
return res, nil
|
1668
|
+
}
|
1669
|
+
|
1670
|
+
cs.bufPipe = pipe{b: &dataBuffer{expected: res.ContentLength}}
|
1671
|
+
cs.bytesRemain = res.ContentLength
|
1672
|
+
res.Body = transportResponseBody{cs}
|
1673
|
+
go cs.awaitRequestCancel(cs.req)
|
1674
|
+
|
1675
|
+
if cs.requestedGzip && res.Header.Get("Content-Encoding") == "gzip" {
|
1676
|
+
res.Header.Del("Content-Encoding")
|
1677
|
+
res.Header.Del("Content-Length")
|
1678
|
+
res.ContentLength = -1
|
1679
|
+
res.Body = &gzipReader{body: res.Body}
|
1680
|
+
setResponseUncompressed(res)
|
1681
|
+
}
|
1682
|
+
return res, nil
|
1683
|
+
}
|
1684
|
+
|
1685
|
+
func (rl *clientConnReadLoop) processTrailers(cs *clientStream, f *MetaHeadersFrame) error {
|
1686
|
+
if cs.pastTrailers {
|
1687
|
+
// Too many HEADERS frames for this stream.
|
1688
|
+
return ConnectionError(ErrCodeProtocol)
|
1689
|
+
}
|
1690
|
+
cs.pastTrailers = true
|
1691
|
+
if !f.StreamEnded() {
|
1692
|
+
// We expect that any headers for trailers also
|
1693
|
+
// has END_STREAM.
|
1694
|
+
return ConnectionError(ErrCodeProtocol)
|
1695
|
+
}
|
1696
|
+
if len(f.PseudoFields()) > 0 {
|
1697
|
+
// No pseudo header fields are defined for trailers.
|
1698
|
+
// TODO: ConnectionError might be overly harsh? Check.
|
1699
|
+
return ConnectionError(ErrCodeProtocol)
|
1700
|
+
}
|
1701
|
+
|
1702
|
+
trailer := make(http.Header)
|
1703
|
+
for _, hf := range f.RegularFields() {
|
1704
|
+
key := http.CanonicalHeaderKey(hf.Name)
|
1705
|
+
trailer[key] = append(trailer[key], hf.Value)
|
1706
|
+
}
|
1707
|
+
cs.trailer = trailer
|
1708
|
+
|
1709
|
+
rl.endStream(cs)
|
1710
|
+
return nil
|
1711
|
+
}
|
1712
|
+
|
1713
|
+
// transportResponseBody is the concrete type of Transport.RoundTrip's
|
1714
|
+
// Response.Body. It is an io.ReadCloser. On Read, it reads from cs.body.
|
1715
|
+
// On Close it sends RST_STREAM if EOF wasn't already seen.
|
1716
|
+
type transportResponseBody struct {
|
1717
|
+
cs *clientStream
|
1718
|
+
}
|
1719
|
+
|
1720
|
+
func (b transportResponseBody) Read(p []byte) (n int, err error) {
|
1721
|
+
cs := b.cs
|
1722
|
+
cc := cs.cc
|
1723
|
+
|
1724
|
+
if cs.readErr != nil {
|
1725
|
+
return 0, cs.readErr
|
1726
|
+
}
|
1727
|
+
n, err = b.cs.bufPipe.Read(p)
|
1728
|
+
if cs.bytesRemain != -1 {
|
1729
|
+
if int64(n) > cs.bytesRemain {
|
1730
|
+
n = int(cs.bytesRemain)
|
1731
|
+
if err == nil {
|
1732
|
+
err = errors.New("net/http: server replied with more than declared Content-Length; truncated")
|
1733
|
+
cc.writeStreamReset(cs.ID, ErrCodeProtocol, err)
|
1734
|
+
}
|
1735
|
+
cs.readErr = err
|
1736
|
+
return int(cs.bytesRemain), err
|
1737
|
+
}
|
1738
|
+
cs.bytesRemain -= int64(n)
|
1739
|
+
if err == io.EOF && cs.bytesRemain > 0 {
|
1740
|
+
err = io.ErrUnexpectedEOF
|
1741
|
+
cs.readErr = err
|
1742
|
+
return n, err
|
1743
|
+
}
|
1744
|
+
}
|
1745
|
+
if n == 0 {
|
1746
|
+
// No flow control tokens to send back.
|
1747
|
+
return
|
1748
|
+
}
|
1749
|
+
|
1750
|
+
cc.mu.Lock()
|
1751
|
+
defer cc.mu.Unlock()
|
1752
|
+
|
1753
|
+
var connAdd, streamAdd int32
|
1754
|
+
// Check the conn-level first, before the stream-level.
|
1755
|
+
if v := cc.inflow.available(); v < transportDefaultConnFlow/2 {
|
1756
|
+
connAdd = transportDefaultConnFlow - v
|
1757
|
+
cc.inflow.add(connAdd)
|
1758
|
+
}
|
1759
|
+
if err == nil { // No need to refresh if the stream is over or failed.
|
1760
|
+
// Consider any buffered body data (read from the conn but not
|
1761
|
+
// consumed by the client) when computing flow control for this
|
1762
|
+
// stream.
|
1763
|
+
v := int(cs.inflow.available()) + cs.bufPipe.Len()
|
1764
|
+
if v < transportDefaultStreamFlow-transportDefaultStreamMinRefresh {
|
1765
|
+
streamAdd = int32(transportDefaultStreamFlow - v)
|
1766
|
+
cs.inflow.add(streamAdd)
|
1767
|
+
}
|
1768
|
+
}
|
1769
|
+
if connAdd != 0 || streamAdd != 0 {
|
1770
|
+
cc.wmu.Lock()
|
1771
|
+
defer cc.wmu.Unlock()
|
1772
|
+
if connAdd != 0 {
|
1773
|
+
cc.fr.WriteWindowUpdate(0, mustUint31(connAdd))
|
1774
|
+
}
|
1775
|
+
if streamAdd != 0 {
|
1776
|
+
cc.fr.WriteWindowUpdate(cs.ID, mustUint31(streamAdd))
|
1777
|
+
}
|
1778
|
+
cc.bw.Flush()
|
1779
|
+
}
|
1780
|
+
return
|
1781
|
+
}
|
1782
|
+
|
1783
|
+
var errClosedResponseBody = errors.New("http2: response body closed")
|
1784
|
+
|
1785
|
+
func (b transportResponseBody) Close() error {
|
1786
|
+
cs := b.cs
|
1787
|
+
cc := cs.cc
|
1788
|
+
|
1789
|
+
serverSentStreamEnd := cs.bufPipe.Err() == io.EOF
|
1790
|
+
unread := cs.bufPipe.Len()
|
1791
|
+
|
1792
|
+
if unread > 0 || !serverSentStreamEnd {
|
1793
|
+
cc.mu.Lock()
|
1794
|
+
cc.wmu.Lock()
|
1795
|
+
if !serverSentStreamEnd {
|
1796
|
+
cc.fr.WriteRSTStream(cs.ID, ErrCodeCancel)
|
1797
|
+
cs.didReset = true
|
1798
|
+
}
|
1799
|
+
// Return connection-level flow control.
|
1800
|
+
if unread > 0 {
|
1801
|
+
cc.inflow.add(int32(unread))
|
1802
|
+
cc.fr.WriteWindowUpdate(0, uint32(unread))
|
1803
|
+
}
|
1804
|
+
cc.bw.Flush()
|
1805
|
+
cc.wmu.Unlock()
|
1806
|
+
cc.mu.Unlock()
|
1807
|
+
}
|
1808
|
+
|
1809
|
+
cs.bufPipe.BreakWithError(errClosedResponseBody)
|
1810
|
+
cc.forgetStreamID(cs.ID)
|
1811
|
+
return nil
|
1812
|
+
}
|
1813
|
+
|
1814
|
+
func (rl *clientConnReadLoop) processData(f *DataFrame) error {
|
1815
|
+
cc := rl.cc
|
1816
|
+
cs := cc.streamByID(f.StreamID, f.StreamEnded())
|
1817
|
+
data := f.Data()
|
1818
|
+
if cs == nil {
|
1819
|
+
cc.mu.Lock()
|
1820
|
+
neverSent := cc.nextStreamID
|
1821
|
+
cc.mu.Unlock()
|
1822
|
+
if f.StreamID >= neverSent {
|
1823
|
+
// We never asked for this.
|
1824
|
+
cc.logf("http2: Transport received unsolicited DATA frame; closing connection")
|
1825
|
+
return ConnectionError(ErrCodeProtocol)
|
1826
|
+
}
|
1827
|
+
// We probably did ask for this, but canceled. Just ignore it.
|
1828
|
+
// TODO: be stricter here? only silently ignore things which
|
1829
|
+
// we canceled, but not things which were closed normally
|
1830
|
+
// by the peer? Tough without accumulating too much state.
|
1831
|
+
|
1832
|
+
// But at least return their flow control:
|
1833
|
+
if f.Length > 0 {
|
1834
|
+
cc.mu.Lock()
|
1835
|
+
cc.inflow.add(int32(f.Length))
|
1836
|
+
cc.mu.Unlock()
|
1837
|
+
|
1838
|
+
cc.wmu.Lock()
|
1839
|
+
cc.fr.WriteWindowUpdate(0, uint32(f.Length))
|
1840
|
+
cc.bw.Flush()
|
1841
|
+
cc.wmu.Unlock()
|
1842
|
+
}
|
1843
|
+
return nil
|
1844
|
+
}
|
1845
|
+
if !cs.firstByte {
|
1846
|
+
cc.logf("protocol error: received DATA before a HEADERS frame")
|
1847
|
+
rl.endStreamError(cs, StreamError{
|
1848
|
+
StreamID: f.StreamID,
|
1849
|
+
Code: ErrCodeProtocol,
|
1850
|
+
})
|
1851
|
+
return nil
|
1852
|
+
}
|
1853
|
+
if f.Length > 0 {
|
1854
|
+
// Check connection-level flow control.
|
1855
|
+
cc.mu.Lock()
|
1856
|
+
if cs.inflow.available() >= int32(f.Length) {
|
1857
|
+
cs.inflow.take(int32(f.Length))
|
1858
|
+
} else {
|
1859
|
+
cc.mu.Unlock()
|
1860
|
+
return ConnectionError(ErrCodeFlowControl)
|
1861
|
+
}
|
1862
|
+
// Return any padded flow control now, since we won't
|
1863
|
+
// refund it later on body reads.
|
1864
|
+
var refund int
|
1865
|
+
if pad := int(f.Length) - len(data); pad > 0 {
|
1866
|
+
refund += pad
|
1867
|
+
}
|
1868
|
+
// Return len(data) now if the stream is already closed,
|
1869
|
+
// since data will never be read.
|
1870
|
+
didReset := cs.didReset
|
1871
|
+
if didReset {
|
1872
|
+
refund += len(data)
|
1873
|
+
}
|
1874
|
+
if refund > 0 {
|
1875
|
+
cc.inflow.add(int32(refund))
|
1876
|
+
cc.wmu.Lock()
|
1877
|
+
cc.fr.WriteWindowUpdate(0, uint32(refund))
|
1878
|
+
if !didReset {
|
1879
|
+
cs.inflow.add(int32(refund))
|
1880
|
+
cc.fr.WriteWindowUpdate(cs.ID, uint32(refund))
|
1881
|
+
}
|
1882
|
+
cc.bw.Flush()
|
1883
|
+
cc.wmu.Unlock()
|
1884
|
+
}
|
1885
|
+
cc.mu.Unlock()
|
1886
|
+
|
1887
|
+
if len(data) > 0 && !didReset {
|
1888
|
+
if _, err := cs.bufPipe.Write(data); err != nil {
|
1889
|
+
rl.endStreamError(cs, err)
|
1890
|
+
return err
|
1891
|
+
}
|
1892
|
+
}
|
1893
|
+
}
|
1894
|
+
|
1895
|
+
if f.StreamEnded() {
|
1896
|
+
rl.endStream(cs)
|
1897
|
+
}
|
1898
|
+
return nil
|
1899
|
+
}
|
1900
|
+
|
1901
|
+
var errInvalidTrailers = errors.New("http2: invalid trailers")
|
1902
|
+
|
1903
|
+
func (rl *clientConnReadLoop) endStream(cs *clientStream) {
|
1904
|
+
// TODO: check that any declared content-length matches, like
|
1905
|
+
// server.go's (*stream).endStream method.
|
1906
|
+
rl.endStreamError(cs, nil)
|
1907
|
+
}
|
1908
|
+
|
1909
|
+
func (rl *clientConnReadLoop) endStreamError(cs *clientStream, err error) {
|
1910
|
+
var code func()
|
1911
|
+
if err == nil {
|
1912
|
+
err = io.EOF
|
1913
|
+
code = cs.copyTrailers
|
1914
|
+
}
|
1915
|
+
cs.bufPipe.closeWithErrorAndCode(err, code)
|
1916
|
+
delete(rl.activeRes, cs.ID)
|
1917
|
+
if isConnectionCloseRequest(cs.req) {
|
1918
|
+
rl.closeWhenIdle = true
|
1919
|
+
}
|
1920
|
+
|
1921
|
+
select {
|
1922
|
+
case cs.resc <- resAndError{err: err}:
|
1923
|
+
default:
|
1924
|
+
}
|
1925
|
+
}
|
1926
|
+
|
1927
|
+
func (cs *clientStream) copyTrailers() {
|
1928
|
+
for k, vv := range cs.trailer {
|
1929
|
+
t := cs.resTrailer
|
1930
|
+
if *t == nil {
|
1931
|
+
*t = make(http.Header)
|
1932
|
+
}
|
1933
|
+
(*t)[k] = vv
|
1934
|
+
}
|
1935
|
+
}
|
1936
|
+
|
1937
|
+
func (rl *clientConnReadLoop) processGoAway(f *GoAwayFrame) error {
|
1938
|
+
cc := rl.cc
|
1939
|
+
cc.t.connPool().MarkDead(cc)
|
1940
|
+
if f.ErrCode != 0 {
|
1941
|
+
// TODO: deal with GOAWAY more. particularly the error code
|
1942
|
+
cc.vlogf("transport got GOAWAY with error code = %v", f.ErrCode)
|
1943
|
+
}
|
1944
|
+
cc.setGoAway(f)
|
1945
|
+
return nil
|
1946
|
+
}
|
1947
|
+
|
1948
|
+
func (rl *clientConnReadLoop) processSettings(f *SettingsFrame) error {
|
1949
|
+
cc := rl.cc
|
1950
|
+
cc.mu.Lock()
|
1951
|
+
defer cc.mu.Unlock()
|
1952
|
+
|
1953
|
+
if f.IsAck() {
|
1954
|
+
if cc.wantSettingsAck {
|
1955
|
+
cc.wantSettingsAck = false
|
1956
|
+
return nil
|
1957
|
+
}
|
1958
|
+
return ConnectionError(ErrCodeProtocol)
|
1959
|
+
}
|
1960
|
+
|
1961
|
+
err := f.ForeachSetting(func(s Setting) error {
|
1962
|
+
switch s.ID {
|
1963
|
+
case SettingMaxFrameSize:
|
1964
|
+
cc.maxFrameSize = s.Val
|
1965
|
+
case SettingMaxConcurrentStreams:
|
1966
|
+
cc.maxConcurrentStreams = s.Val
|
1967
|
+
case SettingMaxHeaderListSize:
|
1968
|
+
cc.peerMaxHeaderListSize = uint64(s.Val)
|
1969
|
+
case SettingInitialWindowSize:
|
1970
|
+
// Values above the maximum flow-control
|
1971
|
+
// window size of 2^31-1 MUST be treated as a
|
1972
|
+
// connection error (Section 5.4.1) of type
|
1973
|
+
// FLOW_CONTROL_ERROR.
|
1974
|
+
if s.Val > math.MaxInt32 {
|
1975
|
+
return ConnectionError(ErrCodeFlowControl)
|
1976
|
+
}
|
1977
|
+
|
1978
|
+
// Adjust flow control of currently-open
|
1979
|
+
// frames by the difference of the old initial
|
1980
|
+
// window size and this one.
|
1981
|
+
delta := int32(s.Val) - int32(cc.initialWindowSize)
|
1982
|
+
for _, cs := range cc.streams {
|
1983
|
+
cs.flow.add(delta)
|
1984
|
+
}
|
1985
|
+
cc.cond.Broadcast()
|
1986
|
+
|
1987
|
+
cc.initialWindowSize = s.Val
|
1988
|
+
default:
|
1989
|
+
// TODO(bradfitz): handle more settings? SETTINGS_HEADER_TABLE_SIZE probably.
|
1990
|
+
cc.vlogf("Unhandled Setting: %v", s)
|
1991
|
+
}
|
1992
|
+
return nil
|
1993
|
+
})
|
1994
|
+
if err != nil {
|
1995
|
+
return err
|
1996
|
+
}
|
1997
|
+
|
1998
|
+
cc.wmu.Lock()
|
1999
|
+
defer cc.wmu.Unlock()
|
2000
|
+
|
2001
|
+
cc.fr.WriteSettingsAck()
|
2002
|
+
cc.bw.Flush()
|
2003
|
+
return cc.werr
|
2004
|
+
}
|
2005
|
+
|
2006
|
+
func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error {
|
2007
|
+
cc := rl.cc
|
2008
|
+
cs := cc.streamByID(f.StreamID, false)
|
2009
|
+
if f.StreamID != 0 && cs == nil {
|
2010
|
+
return nil
|
2011
|
+
}
|
2012
|
+
|
2013
|
+
cc.mu.Lock()
|
2014
|
+
defer cc.mu.Unlock()
|
2015
|
+
|
2016
|
+
fl := &cc.flow
|
2017
|
+
if cs != nil {
|
2018
|
+
fl = &cs.flow
|
2019
|
+
}
|
2020
|
+
if !fl.add(int32(f.Increment)) {
|
2021
|
+
return ConnectionError(ErrCodeFlowControl)
|
2022
|
+
}
|
2023
|
+
cc.cond.Broadcast()
|
2024
|
+
return nil
|
2025
|
+
}
|
2026
|
+
|
2027
|
+
func (rl *clientConnReadLoop) processResetStream(f *RSTStreamFrame) error {
|
2028
|
+
cs := rl.cc.streamByID(f.StreamID, true)
|
2029
|
+
if cs == nil {
|
2030
|
+
// TODO: return error if server tries to RST_STEAM an idle stream
|
2031
|
+
return nil
|
2032
|
+
}
|
2033
|
+
select {
|
2034
|
+
case <-cs.peerReset:
|
2035
|
+
// Already reset.
|
2036
|
+
// This is the only goroutine
|
2037
|
+
// which closes this, so there
|
2038
|
+
// isn't a race.
|
2039
|
+
default:
|
2040
|
+
err := streamError(cs.ID, f.ErrCode)
|
2041
|
+
cs.resetErr = err
|
2042
|
+
close(cs.peerReset)
|
2043
|
+
cs.bufPipe.CloseWithError(err)
|
2044
|
+
cs.cc.cond.Broadcast() // wake up checkResetOrDone via clientStream.awaitFlowControl
|
2045
|
+
}
|
2046
|
+
delete(rl.activeRes, cs.ID)
|
2047
|
+
return nil
|
2048
|
+
}
|
2049
|
+
|
2050
|
+
// Ping sends a PING frame to the server and waits for the ack.
|
2051
|
+
// Public implementation is in go17.go and not_go17.go
|
2052
|
+
func (cc *ClientConn) ping(ctx contextContext) error {
|
2053
|
+
c := make(chan struct{})
|
2054
|
+
// Generate a random payload
|
2055
|
+
var p [8]byte
|
2056
|
+
for {
|
2057
|
+
if _, err := rand.Read(p[:]); err != nil {
|
2058
|
+
return err
|
2059
|
+
}
|
2060
|
+
cc.mu.Lock()
|
2061
|
+
// check for dup before insert
|
2062
|
+
if _, found := cc.pings[p]; !found {
|
2063
|
+
cc.pings[p] = c
|
2064
|
+
cc.mu.Unlock()
|
2065
|
+
break
|
2066
|
+
}
|
2067
|
+
cc.mu.Unlock()
|
2068
|
+
}
|
2069
|
+
cc.wmu.Lock()
|
2070
|
+
if err := cc.fr.WritePing(false, p); err != nil {
|
2071
|
+
cc.wmu.Unlock()
|
2072
|
+
return err
|
2073
|
+
}
|
2074
|
+
if err := cc.bw.Flush(); err != nil {
|
2075
|
+
cc.wmu.Unlock()
|
2076
|
+
return err
|
2077
|
+
}
|
2078
|
+
cc.wmu.Unlock()
|
2079
|
+
select {
|
2080
|
+
case <-c:
|
2081
|
+
return nil
|
2082
|
+
case <-ctx.Done():
|
2083
|
+
return ctx.Err()
|
2084
|
+
case <-cc.readerDone:
|
2085
|
+
// connection closed
|
2086
|
+
return cc.readerErr
|
2087
|
+
}
|
2088
|
+
}
|
2089
|
+
|
2090
|
+
func (rl *clientConnReadLoop) processPing(f *PingFrame) error {
|
2091
|
+
if f.IsAck() {
|
2092
|
+
cc := rl.cc
|
2093
|
+
cc.mu.Lock()
|
2094
|
+
defer cc.mu.Unlock()
|
2095
|
+
// If ack, notify listener if any
|
2096
|
+
if c, ok := cc.pings[f.Data]; ok {
|
2097
|
+
close(c)
|
2098
|
+
delete(cc.pings, f.Data)
|
2099
|
+
}
|
2100
|
+
return nil
|
2101
|
+
}
|
2102
|
+
cc := rl.cc
|
2103
|
+
cc.wmu.Lock()
|
2104
|
+
defer cc.wmu.Unlock()
|
2105
|
+
if err := cc.fr.WritePing(true, f.Data); err != nil {
|
2106
|
+
return err
|
2107
|
+
}
|
2108
|
+
return cc.bw.Flush()
|
2109
|
+
}
|
2110
|
+
|
2111
|
+
func (rl *clientConnReadLoop) processPushPromise(f *PushPromiseFrame) error {
|
2112
|
+
// We told the peer we don't want them.
|
2113
|
+
// Spec says:
|
2114
|
+
// "PUSH_PROMISE MUST NOT be sent if the SETTINGS_ENABLE_PUSH
|
2115
|
+
// setting of the peer endpoint is set to 0. An endpoint that
|
2116
|
+
// has set this setting and has received acknowledgement MUST
|
2117
|
+
// treat the receipt of a PUSH_PROMISE frame as a connection
|
2118
|
+
// error (Section 5.4.1) of type PROTOCOL_ERROR."
|
2119
|
+
return ConnectionError(ErrCodeProtocol)
|
2120
|
+
}
|
2121
|
+
|
2122
|
+
func (cc *ClientConn) writeStreamReset(streamID uint32, code ErrCode, err error) {
|
2123
|
+
// TODO: map err to more interesting error codes, once the
|
2124
|
+
// HTTP community comes up with some. But currently for
|
2125
|
+
// RST_STREAM there's no equivalent to GOAWAY frame's debug
|
2126
|
+
// data, and the error codes are all pretty vague ("cancel").
|
2127
|
+
cc.wmu.Lock()
|
2128
|
+
cc.fr.WriteRSTStream(streamID, code)
|
2129
|
+
cc.bw.Flush()
|
2130
|
+
cc.wmu.Unlock()
|
2131
|
+
}
|
2132
|
+
|
2133
|
+
var (
|
2134
|
+
errResponseHeaderListSize = errors.New("http2: response header list larger than advertised limit")
|
2135
|
+
errRequestHeaderListSize = errors.New("http2: request header list larger than peer's advertised limit")
|
2136
|
+
errPseudoTrailers = errors.New("http2: invalid pseudo header in trailers")
|
2137
|
+
)
|
2138
|
+
|
2139
|
+
func (cc *ClientConn) logf(format string, args ...interface{}) {
|
2140
|
+
cc.t.logf(format, args...)
|
2141
|
+
}
|
2142
|
+
|
2143
|
+
func (cc *ClientConn) vlogf(format string, args ...interface{}) {
|
2144
|
+
cc.t.vlogf(format, args...)
|
2145
|
+
}
|
2146
|
+
|
2147
|
+
func (t *Transport) vlogf(format string, args ...interface{}) {
|
2148
|
+
if VerboseLogs {
|
2149
|
+
t.logf(format, args...)
|
2150
|
+
}
|
2151
|
+
}
|
2152
|
+
|
2153
|
+
func (t *Transport) logf(format string, args ...interface{}) {
|
2154
|
+
log.Printf(format, args...)
|
2155
|
+
}
|
2156
|
+
|
2157
|
+
var noBody io.ReadCloser = ioutil.NopCloser(bytes.NewReader(nil))
|
2158
|
+
|
2159
|
+
func strSliceContains(ss []string, s string) bool {
|
2160
|
+
for _, v := range ss {
|
2161
|
+
if v == s {
|
2162
|
+
return true
|
2163
|
+
}
|
2164
|
+
}
|
2165
|
+
return false
|
2166
|
+
}
|
2167
|
+
|
2168
|
+
type erringRoundTripper struct{ err error }
|
2169
|
+
|
2170
|
+
func (rt erringRoundTripper) RoundTrip(*http.Request) (*http.Response, error) { return nil, rt.err }
|
2171
|
+
|
2172
|
+
// gzipReader wraps a response body so it can lazily
|
2173
|
+
// call gzip.NewReader on the first call to Read
|
2174
|
+
type gzipReader struct {
|
2175
|
+
body io.ReadCloser // underlying Response.Body
|
2176
|
+
zr *gzip.Reader // lazily-initialized gzip reader
|
2177
|
+
zerr error // sticky error
|
2178
|
+
}
|
2179
|
+
|
2180
|
+
func (gz *gzipReader) Read(p []byte) (n int, err error) {
|
2181
|
+
if gz.zerr != nil {
|
2182
|
+
return 0, gz.zerr
|
2183
|
+
}
|
2184
|
+
if gz.zr == nil {
|
2185
|
+
gz.zr, err = gzip.NewReader(gz.body)
|
2186
|
+
if err != nil {
|
2187
|
+
gz.zerr = err
|
2188
|
+
return 0, err
|
2189
|
+
}
|
2190
|
+
}
|
2191
|
+
return gz.zr.Read(p)
|
2192
|
+
}
|
2193
|
+
|
2194
|
+
func (gz *gzipReader) Close() error {
|
2195
|
+
return gz.body.Close()
|
2196
|
+
}
|
2197
|
+
|
2198
|
+
type errorReader struct{ err error }
|
2199
|
+
|
2200
|
+
func (r errorReader) Read(p []byte) (int, error) { return 0, r.err }
|
2201
|
+
|
2202
|
+
// bodyWriterState encapsulates various state around the Transport's writing
|
2203
|
+
// of the request body, particularly regarding doing delayed writes of the body
|
2204
|
+
// when the request contains "Expect: 100-continue".
|
2205
|
+
type bodyWriterState struct {
|
2206
|
+
cs *clientStream
|
2207
|
+
timer *time.Timer // if non-nil, we're doing a delayed write
|
2208
|
+
fnonce *sync.Once // to call fn with
|
2209
|
+
fn func() // the code to run in the goroutine, writing the body
|
2210
|
+
resc chan error // result of fn's execution
|
2211
|
+
delay time.Duration // how long we should delay a delayed write for
|
2212
|
+
}
|
2213
|
+
|
2214
|
+
func (t *Transport) getBodyWriterState(cs *clientStream, body io.Reader) (s bodyWriterState) {
|
2215
|
+
s.cs = cs
|
2216
|
+
if body == nil {
|
2217
|
+
return
|
2218
|
+
}
|
2219
|
+
resc := make(chan error, 1)
|
2220
|
+
s.resc = resc
|
2221
|
+
s.fn = func() {
|
2222
|
+
cs.cc.mu.Lock()
|
2223
|
+
cs.startedWrite = true
|
2224
|
+
cs.cc.mu.Unlock()
|
2225
|
+
resc <- cs.writeRequestBody(body, cs.req.Body)
|
2226
|
+
}
|
2227
|
+
s.delay = t.expectContinueTimeout()
|
2228
|
+
if s.delay == 0 ||
|
2229
|
+
!httplex.HeaderValuesContainsToken(
|
2230
|
+
cs.req.Header["Expect"],
|
2231
|
+
"100-continue") {
|
2232
|
+
return
|
2233
|
+
}
|
2234
|
+
s.fnonce = new(sync.Once)
|
2235
|
+
|
2236
|
+
// Arm the timer with a very large duration, which we'll
|
2237
|
+
// intentionally lower later. It has to be large now because
|
2238
|
+
// we need a handle to it before writing the headers, but the
|
2239
|
+
// s.delay value is defined to not start until after the
|
2240
|
+
// request headers were written.
|
2241
|
+
const hugeDuration = 365 * 24 * time.Hour
|
2242
|
+
s.timer = time.AfterFunc(hugeDuration, func() {
|
2243
|
+
s.fnonce.Do(s.fn)
|
2244
|
+
})
|
2245
|
+
return
|
2246
|
+
}
|
2247
|
+
|
2248
|
+
func (s bodyWriterState) cancel() {
|
2249
|
+
if s.timer != nil {
|
2250
|
+
s.timer.Stop()
|
2251
|
+
}
|
2252
|
+
}
|
2253
|
+
|
2254
|
+
func (s bodyWriterState) on100() {
|
2255
|
+
if s.timer == nil {
|
2256
|
+
// If we didn't do a delayed write, ignore the server's
|
2257
|
+
// bogus 100 continue response.
|
2258
|
+
return
|
2259
|
+
}
|
2260
|
+
s.timer.Stop()
|
2261
|
+
go func() { s.fnonce.Do(s.fn) }()
|
2262
|
+
}
|
2263
|
+
|
2264
|
+
// scheduleBodyWrite starts writing the body, either immediately (in
|
2265
|
+
// the common case) or after the delay timeout. It should not be
|
2266
|
+
// called until after the headers have been written.
|
2267
|
+
func (s bodyWriterState) scheduleBodyWrite() {
|
2268
|
+
if s.timer == nil {
|
2269
|
+
// We're not doing a delayed write (see
|
2270
|
+
// getBodyWriterState), so just start the writing
|
2271
|
+
// goroutine immediately.
|
2272
|
+
go s.fn()
|
2273
|
+
return
|
2274
|
+
}
|
2275
|
+
traceWait100Continue(s.cs.trace)
|
2276
|
+
if s.timer.Stop() {
|
2277
|
+
s.timer.Reset(s.delay)
|
2278
|
+
}
|
2279
|
+
}
|
2280
|
+
|
2281
|
+
// isConnectionCloseRequest reports whether req should use its own
|
2282
|
+
// connection for a single request and then close the connection.
|
2283
|
+
func isConnectionCloseRequest(req *http.Request) bool {
|
2284
|
+
return req.Close || httplex.HeaderValuesContainsToken(req.Header["Connection"], "close")
|
2285
|
+
}
|