mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
ignore HTTP2 PRIORITY frames in the server
This commit is contained in:
parent
1fc6c5a14c
commit
d0897fa0b3
2 changed files with 28 additions and 2 deletions
|
@ -154,10 +154,18 @@ func (s *Server) handleRequest(session streamCreator, headerStream quic.Stream,
|
|||
if err != nil {
|
||||
return qerr.Error(qerr.HeadersStreamDataDecompressFailure, "cannot read frame")
|
||||
}
|
||||
h2headersFrame, ok := h2frame.(*http2.HeadersFrame)
|
||||
if !ok {
|
||||
var h2headersFrame *http2.HeadersFrame
|
||||
switch f := h2frame.(type) {
|
||||
case *http2.PriorityFrame:
|
||||
// ignore PRIORITY frames
|
||||
s.logger.Debugf("Ignoring H2 PRIORITY frame: %#v", f)
|
||||
return nil
|
||||
case *http2.HeadersFrame:
|
||||
h2headersFrame = f
|
||||
default:
|
||||
return qerr.Error(qerr.InvalidHeadersStreamData, "expected a header frame")
|
||||
}
|
||||
|
||||
if !h2headersFrame.HeadersEnded() {
|
||||
return errors.New("http2 header continuation not implemented")
|
||||
}
|
||||
|
|
|
@ -259,6 +259,24 @@ var _ = Describe("H2 server", func() {
|
|||
Expect(dataStream.reset).To(BeFalse())
|
||||
})
|
||||
|
||||
It("ignores PRIORITY frames", func() {
|
||||
handlerCalled := make(chan struct{})
|
||||
s.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
close(handlerCalled)
|
||||
})
|
||||
buf := &bytes.Buffer{}
|
||||
framer := http2.NewFramer(buf, nil)
|
||||
err := framer.WritePriority(10, http2.PriorityParam{Weight: 42})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(buf.Bytes()).ToNot(BeEmpty())
|
||||
headerStream.dataToRead.Write(buf.Bytes())
|
||||
err = s.handleRequest(session, headerStream, &sync.Mutex{}, hpackDecoder, h2framer)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Consistently(handlerCalled).ShouldNot(BeClosed())
|
||||
Expect(dataStream.reset).To(BeFalse())
|
||||
Expect(dataStream.closed).To(BeFalse())
|
||||
})
|
||||
|
||||
It("errors when non-header frames are received", func() {
|
||||
headerStream.dataToRead.Write([]byte{
|
||||
0x0, 0x0, 0x06, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue