I am using *golang.org/x/net/http2* and *golang.org/x/net/http2/**hpack* 
packages to do low level http2 framing. For requests with only HEADERS 
frame sent, I want to send a empy json '{}', so I send 1 HEADERS frame and 
1 DATA frame as below 

                headersframe, ok := frame.(*http2.HeadersFrame)
if ok {
println("headers frame detected")

if headersframe.StreamEnded() {
                 
// write HEADERS frame with 2 headers
      
hbytes := make([]byte, 0, 2048)
hbuffer := bytes.NewBuffer(hbytes)
hfield1 := hpack.HeaderField{
Name: ":status",
Value: "200",
Sensitive: false,}
hfield2 := hpack.HeaderField{
Name: "content-type",
Value: "application/json",
Sensitive: false,}

encoder := hpack.NewEncoder(hbuffer)
err := encoder.WriteField(hfield1)
err = encoder.WriteField(hfield2)
if err != nil {
println(err.Error())
}
hfp := http2.HeadersFrameParam{
StreamID: frame.Header().StreamID,
BlockFragment: hbuffer.Bytes(),
EndStream: false,
EndHeaders: true,
}
err = framer.WriteHeaders(hfp)
if err != nil {
println(err.Error())
}

// write DATA frame

data := []byte("{}")
framer.WriteData(frame.Header().StreamID, true, data)
                        }
return
}

On trying with *curl -v https://127.0.0.1:8000 -k --http2*, I get error as 
- 

                curl: (16) Error in the HTTP2 framing layer

Is anything missing in my way of framing response?

-- 
*::DISCLAIMER::

----------------------------------------------------------------------------------------------------------------------------------------------------


The contents of this e-mail and any attachments are confidential and 
intended for the named recipient(s) only.E-mail transmission is not 
guaranteed to be secure or error-free as information could be intercepted, 
corrupted,lost, destroyed, arrive late or incomplete, or may contain 
viruses in transmission. The e mail and its contents(with or without 
referred errors) shall therefore not attach any liability on the originator 
or redBus.com. Views or opinions, if any, presented in this email are 
solely those of the author and may not necessarily reflect the views or 
opinions of redBus.com. Any form of reproduction, dissemination, copying, 
disclosure, modification,distribution and / or publication of this message 
without the prior written consent of authorized representative of redbus. 
<http://redbus.in/>com is strictly prohibited. If you have received this 
email in error please delete it and notify the sender immediately.Before 
opening any email and/or attachments, please check them for viruses and 
other defects.*

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to