SlyMarbo / spdy

[deprecated] A full-featured SPDY library for the Go language.
BSD 2-Clause "Simplified" License
116 stars 13 forks source link

Running spdy with negroni results in no spdy support. #80

Closed ssoroka closed 9 years ago

ssoroka commented 9 years ago

Running spdy with negroni results in no spdy support.

Example code:

import (
  "github.com/codegangsta/negroni"
  "github.com/SlyMarbo/spdy"
  "net/http"
  "fmt"
)

mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "%f", spdy.SPDYversion(w))
})
n := negroni.New()
n.UseHandler(mux)

err := spdy.ListenAndServeTLS(":443", "cert.pem", "key.pem", n)
SlyMarbo commented 9 years ago

This is because Negroni is wrapping the http.ResponseWriter in its own structure, so spdy.SPDYversion can't see the spdy ResponseWriter. However, it should still be using SPDY. Negroni doesn't export their ResponseWriter (negroni.responseWriter), so it's tricky to solve without Negroni changing their API.