diff options
author | Corey Hulen <corey@hulen.com> | 2017-03-24 23:31:34 -0700 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2017-03-25 03:31:34 -0300 |
commit | 54d3d47daf9190275bbdaf8703b84969a4593451 (patch) | |
tree | 05899b296d0186c1a0da8a540bc486e34ad8eec9 /vendor/golang.org/x/net/http2/h2demo | |
parent | 7460302dec7796e01c98264e84bece8169cb6ed9 (diff) | |
download | chat-54d3d47daf9190275bbdaf8703b84969a4593451.tar.gz chat-54d3d47daf9190275bbdaf8703b84969a4593451.tar.bz2 chat-54d3d47daf9190275bbdaf8703b84969a4593451.zip |
PLT-6076 Adding viper libs for config file changes (#5871)
* Adding viper libs for config file changes
* Removing the old fsnotify lib
* updating some missing libs
Diffstat (limited to 'vendor/golang.org/x/net/http2/h2demo')
-rw-r--r-- | vendor/golang.org/x/net/http2/h2demo/h2demo.go | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/vendor/golang.org/x/net/http2/h2demo/h2demo.go b/vendor/golang.org/x/net/http2/h2demo/h2demo.go index 980b6d67d..fa5978ee5 100644 --- a/vendor/golang.org/x/net/http2/h2demo/h2demo.go +++ b/vendor/golang.org/x/net/http2/h2demo/h2demo.go @@ -313,6 +313,13 @@ func newGopherTilesHandler() http.Handler { } return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ms, _ := strconv.Atoi(r.FormValue("latency")) + push, _ := strconv.ParseBool(r.FormValue("push")) + + cacheBust := time.Now().UnixNano() + if push { + pushTiles(w, cacheBust, ms, xt, yt) + } + const nanosPerMilli = 1e6 if r.FormValue("x") != "" { x, _ := strconv.Atoi(r.FormValue("x")) @@ -329,13 +336,13 @@ func newGopherTilesHandler() http.Handler { fmt.Fprintf(w, "A grid of %d tiled images is below. Compare:<p>", xt*yt) for _, ms := range []int{0, 30, 200, 1000} { d := time.Duration(ms) * nanosPerMilli - fmt.Fprintf(w, "[<a href='https://%s/gophertiles?latency=%d'>HTTP/2, %v latency</a>] [<a href='http://%s/gophertiles?latency=%d'>HTTP/1, %v latency</a>]<br>\n", + fmt.Fprintf(w, "[<a href='https://%s/gophertiles?latency=%d'>HTTP/2, %v latency</a>] [<a href='https://%s/gophertiles?latency=%d&push=true'>HTTP/2, %v latency with Server Push</a>] [<a href='http://%s/gophertiles?latency=%d'>HTTP/1, %v latency</a>]<br>\n", + httpsHost(), ms, d, httpsHost(), ms, d, httpHost(), ms, d, ) } io.WriteString(w, "<p>\n") - cacheBust := time.Now().UnixNano() for y := 0; y < yt; y++ { for x := 0; x < xt; x++ { fmt.Fprintf(w, "<img width=%d height=%d src='/gophertiles?x=%d&y=%d&cachebust=%d&latency=%d'>", @@ -356,6 +363,21 @@ function showtimes() { }) } +func pushTiles(w http.ResponseWriter, cacheBust int64, latency int, xt, yt int) { + pusher, ok := w.(http.Pusher) + if !ok { + return + } + for y := 0; y < yt; y++ { + for x := 0; x < xt; x++ { + img := fmt.Sprintf("/gophertiles?x=%d&y=%d&cachebust=%d&latency=%d", x, y, cacheBust, latency) + if err := pusher.Push(img, nil); err != nil { + log.Printf("Failed to push %v: %v", img, err) + } + } + } +} + func httpsHost() string { if *hostHTTPS != "" { return *hostHTTPS |