jmckaskill / gospdy Goto Github PK
View Code? Open in Web Editor NEWSPDY client/server for Go
SPDY client/server for Go
In gospdy.Transport.RoundTrip(), on line 246, the TLS connection verifies the certificate's hostname, even if this has been disabled in the tls.Config.
My proposed fix replaces:
if err := tlsSock.VerifyHostname(cfg.ServerName); err != nil {
t.lk.Unlock()
tlsSock.Close()
proxySock.Close()
return nil, err
}
with:
if !cfg.InsecureSkipVerify {
if err := tlsSock.VerifyHostname(cfg.ServerName); err != nil {
t.lk.Unlock()
tlsSock.Close()
proxySock.Close()
return nil, err
}
}
In gospdy.Connection.handleSynStream(), on line 474, the created *http.Request does not have Request.URI set. This is the field most commonly used to serve files in an HTTP server.
My proposed fix inserts:
RequestURI: f.URL.Path,
before line 483.
I have tried to write hello world example using gospdy, but was out of luck. Here is my code:
package main
import (
"fmt"
"net/http"
"github.com/jmckaskill/gospdy"
)
type Hello struct{}
func (h Hello) ServeHTTP(
w http.ResponseWriter,
r *http.Request) {
fmt.Fprint(w, "Hello!")
}
func main() {
var h Hello
spdy.ListenAndServe("localhost:4000", h)
}
There were no errors, but localhost:4000 just did not respond.
Given that the connection pool is inside Transport, to have multiple streams on the same connection one must use the same Transport.
However, to make requests with different priorities, the API is to set fields in RequestExtra, and then e.g. http.Client.Get. So, in practice, that would mean one needs to have a mutex protecting RequestExtra, and do something like Lock; RequestExtra.Priority = ...; Get; Unlock
.
I understand that there is no good place for a priority in the net/http APIs. Maybe there could be per-priority RoundTrippers? In fact, all of RequestExtra could be done like that. Something like:
type customTransport struct {
RequestExtra
*Transport
}
func (t *customTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
return t.Transport.roundTrip(req, &t.RequestExtra)
}
func (t *Transport) Custom(extra RequestExtra) http.RoundTripper {
return &customTransport{RequestExtra: extra, Transport: t}
}
func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
return t.roundTrip(req, &RequestExtra{})
}
func (t *Transport) roundTrip(req *http.Request, extra *RequestExtra) (resp *http.Response, err error) {
...
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.