mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 20:57:36 +03:00
Add caching to PR data generation and add a separate prdatalong handler
This commit is contained in:
parent
84db78db83
commit
6150e2d05d
1 changed files with 23 additions and 4 deletions
|
@ -12,7 +12,15 @@ import (
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
dataLen = 500 * 1024 // 500 KB
|
||||||
|
dataLenLong = 50 * 1024 * 1024 // 50 MB
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
PRData = GeneratePRData(dataLen)
|
||||||
|
PRDataLong = GeneratePRData(dataLenLong)
|
||||||
|
|
||||||
server *h2quic.Server
|
server *h2quic.Server
|
||||||
port string
|
port string
|
||||||
)
|
)
|
||||||
|
@ -21,10 +29,21 @@ func init() {
|
||||||
http.HandleFunc("/prdata", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/prdata", func(w http.ResponseWriter, r *http.Request) {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
sl := r.URL.Query().Get("len")
|
sl := r.URL.Query().Get("len")
|
||||||
l, err := strconv.Atoi(sl)
|
if sl != "" {
|
||||||
Expect(err).NotTo(HaveOccurred())
|
var err error
|
||||||
data := GeneratePRData(l)
|
l, err := strconv.Atoi(sl)
|
||||||
_, err = w.Write(data)
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
_, err = w.Write(GeneratePRData(l))
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
} else {
|
||||||
|
_, err := w.Write(PRData)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
http.HandleFunc("/prdatalong", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
defer GinkgoRecover()
|
||||||
|
_, err := w.Write(PRDataLong)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue