Server :
From the readme ,i know how to run this scripty,But,:
$ python quart_example.py
$ python twisted_example.py
next the port maybe exit, so ,we can not run them in the same time.
Client:
About the client,could mind tell how to run this ?
Thanks.
I want to get a Clear text capture for http2.
what should i do?
In order to learn http2 ,i have write a go script for http2 as fllow:
Client:
package main
import (
"crypto/tls"
"fmt"
"log"
"net"
"net/http"
"golang.org/x/net/http2"
Server : From the readme ,i know how to run this scripty,But,: $ python quart_example.py $ python twisted_example.py next the port maybe exit, so ,we can not run them in the same time. Client: About the client,could mind tell how to run this ? Thanks.
I want to get a Clear text capture for http2. what should i do? In order to learn http2 ,i have write a go script for http2 as fllow: Client: package main import ( "crypto/tls" "fmt" "log" "net" "net/http" "golang.org/x/net/http2"
)
func main() { client := http.Client{ // Skip TLS dial Transport: &http2.Transport{ AllowHTTP: true, DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { return net.Dial(network, addr) }, }, } resp, err := client.Get("http://localhost:8080") if err != nil { log.Fatal(fmt.Errorf("error making request: %v", err)) } // fmt.Println(resp) fmt.Println(resp.StatusCode) fmt.Println(resp.Proto) }
Server:
package main import ( "fmt" "golang.org/x/net/http2" "net/http"
)
//net/http包默认可以采用http2进行服务,在没有进行https的服务上开启H2, //需要修改ListenAndServer的默认h2服务
type serverHandler struct { }
func (sh serverHandler) ServeHTTP(w http.ResponseWriter, req http.Request) { fmt.Println(req) w.Header().Set("server", "h2test") w.Write([]byte("this is a http2 test sever")) }
func main() { server := &http.Server{ Addr: ":8080", Handler: &serverHandler{}, ReadTimeout: 5 time.Second, WriteTimeout: 5 time.Second, } //http2.Server.ServeConn() s2 := &http2.Server{ IdleTimeout: 1 * time.Minute, } http2.ConfigureServer(server, s2) l, _ := net.Listen("tcp", ":8080") defer l.Close() fmt.Println("Start server...") for { rwc, err := l.Accept() if err != nil { fmt.Println("accept err:", err) continue } go s2.ServeConn(rwc, &http2.ServeConnOpts{BaseConfig: server})
}
But any flow i can not get from the capture which get by wireshark. this is my goal.