I was wondering how would one go about writing, reading and sending a Frame, for example a Data Frame, using of course HTTP/2. I know Golang library net/http supports this new protocol, but I do not know how to correctly do the above mentioned aspects.
Thank you in advance!
Frames. Frames are the new basic unit of communication in HTTP/2 and replace the familiar header & body format of current HTTP requests/responses. Instead, each piece of communication between the client and server is packed up into a binary “frame” before it is sent over the connection.
HTTP2 Over Cleartext (H2C) However, H2C or “http2 over cleartext” is where a normal transient http connection is upgraded to a persistent connection that uses the http2 binary protocol to communicate continuously instead of for one request using the plaintext http protocol.
H2c is established protocol shorthand for HTTP/2 initiated by a HTTP/1.1 Upgrade header sent over cleartext communication. The attack occurs when a hacker uses h2c to send requests to an intermediary server (known as a proxy server), which can then evade the server access controls.
It establishes network connections as needed 40 // and caches them for reuse by subsequent calls. It uses HTTP proxies 41 // as directed by the $HTTP_PROXY and $NO_PROXY (or $http_proxy and 42 // $no_proxy) environment variables.
try to send http2 request like this
first of all, you need to import http2 package
import "golang.org/x/net/http2"
then, write some request code
t := &http2.Transport{}
c := &http.Client{
Transport: t,
}
r, _ := http.NewRequest("GET", "https://http2.golang.org/reqinfo", bytes.NewBuffer([]byte("hello")))
resp, err := c.Do(r)
if err != nil {
fmt.Printf("request error")
}
defer resp.Body.Close()
content, _ := ioutil.ReadAll(resp.Body)
fmt.Printf("body length:%d\n", len(content))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With