I'm working on hooking up the existing spdy package in
go.net
to net/http. After talking briefly with Brad I'm about ready to
send a small "hello world" CL for
go.net/spdy. If this goes well
I plan to follow up with many more incremental additions until
we support all features of spdy.
Rough strategy: use http.Server.TLSNextProto as it was intended.
Internally, each spdy session will funnel all incoming and outgoing
frames through one goroutine, which will track the state of all its
streams and enforce the spdy framing layer rules (e.g. valid stream
ids, flow control).
I'm happy to discuss this more here or go ahead and send the
change for initial review if it sounds reasonable.
Some things I'm unsure of:
- How much should ultimately be exported?
We might think of spdy in (at least) three layers: the framing
format already provided by
go.net/spdy, the framing layer
communication rules (e.g. multiplexing, flow control), and
the http layer.
I can imagine some people wanting to use each of those
layers, though I expect the vast majority to use only the
high-level net/http hooks.
So I'm not sure about which symbols to make public.
- Split into multiple packages?
Should there be a
go.net/spdy/http, or should everything be
lumped in together? Something else?
- It would be great to reuse more from net/http.
e.g. sniff buffering, multipart forms
A great deal of logic in net/http is specific to http's wire
format (for example, looking through the read buffer to find
the end of chunked encoding for trailer purposes), and I'm
grateful to leave it behind. But buffering part of the response
for sniffing, cleaning up multipart forms temp files, etc could
potentially be shared. Perhaps by exporting a ResponseWriter
wrapper for each one? Not sure if this is too much trouble;
I'm also ok with copying those things over, though of course
keeping up with bug fixes and enhancements will be not fun.
- How best to hook in requests to net/http?
Is there a client-side equivalent of http.Server.TLSNextProto,
so users can make a single call and get either spdy or plain
http, depending on what the remote server advertises?
Will it be possible to share net/http's connection pool?