fix: fix typo in tarball url replacing
This commit is contained in:
parent
2346dbaf87
commit
e2932d3afb
@ -5,6 +5,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -53,9 +54,9 @@ func (proxy Proxy) GetCachedPath(options Options, path string, request *http.Req
|
|||||||
|
|
||||||
pkg = string(body)
|
pkg = string(body)
|
||||||
|
|
||||||
// // TODO: avoid calling MustCompile every time
|
// TODO: avoid calling MustCompile every time
|
||||||
// // find "dist": "https?://.*/ and replace to "dist": "{localurl}/
|
// find "dist": "https?://.*/ and replace to "dist": "{localurl}/
|
||||||
// pkg = regexp.MustCompile(`(?U)"tarball":"https?://.*/`).ReplaceAllString(string(body), `"dist": "http://localhost:8080/`)
|
pkg = regexp.MustCompile(`(?U)"tarball":"https?://.*/`).ReplaceAllString(string(body), `"tarball": "http://`+request.Host+"/")
|
||||||
|
|
||||||
// save to redis
|
// save to redis
|
||||||
err = proxy.Database.Set(key, pkg, options.DatabaseExpiration)
|
err = proxy.Database.Set(key, pkg, options.DatabaseExpiration)
|
||||||
|
12
readme.md
12
readme.md
@ -153,12 +153,12 @@ Macbook Pro 15″ 2017, Intel Core i7-7700HQ. Note `GOMAXPROCS=1`.
|
|||||||
$ go-wrk -c 100 -d 10 http://localhost:8080/ascii
|
$ go-wrk -c 100 -d 10 http://localhost:8080/ascii
|
||||||
Running 10s test @ http://localhost:8080/ascii
|
Running 10s test @ http://localhost:8080/ascii
|
||||||
100 goroutine(s) running concurrently
|
100 goroutine(s) running concurrently
|
||||||
84216 requests in 10.000196326s, 535.30MB read
|
120227 requests in 9.996788553s, 136.21MB read
|
||||||
Requests/sec: 8421.43
|
Requests/sec: 12026.56
|
||||||
Transfer/sec: 53.53MB
|
Transfer/sec: 13.63MB
|
||||||
Avg Req Time: 11.874461ms
|
Avg Req Time: 8.314928ms
|
||||||
Fastest Request: 2.213324ms
|
Fastest Request: 1.157793ms
|
||||||
Slowest Request: 745.874068ms
|
Slowest Request: 782.917402ms
|
||||||
Number of Errors: 0
|
Number of Errors: 0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user