func readRequest(st *framing.Stream) (w *response, err error) { req, err := ReadRequest( st.Header(), nil, st, // TODO(kr): buffer ) if err != nil { return nil, err } w = new(response) w.header = make(http.Header) w.stream = st w.req = req return w, nil }
func (s *Server) serveStream(st *framing.Stream, c net.Conn) { // TODO(kr): recover // TODO(kr): buffered reader and writer w, err := readRequest(st) if err != nil { log.Println("spdy: read request failed:", err) st.Reply(http.Header{":status": {"400"}}, framing.ControlFlagFin) st.Reset(framing.RefusedStream) return } w.req.RemoteAddr = c.RemoteAddr().String() handler := s.Handler if handler == nil { handler = http.DefaultServeMux } handler.ServeHTTP(w, w.req) w.finishRequest() }