Skip to content

Commit a68be36

Browse files
committed
fix bot detection
1 parent 029f7bd commit a68be36

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020

2121
- run: go run github.com/ysmood/golangci-lint@latest
2222

23-
- run: go test -coverprofile=coverage.out ./...
23+
- run: go test ./...

service.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func New(addr, target string) *Bartender {
3333
}
3434

3535
func (b *Bartender) ServeHTTP(w http.ResponseWriter, r *http.Request) {
36-
if r.Method == http.MethodGet && r.Header.Get("Accept-Language") != "" {
36+
if r.Method == http.MethodGet && r.Header.Get("Accept-Language") == "" {
3737
b.RenderPage(w, r)
3838

3939
return

service_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ func TestBasic(t *testing.T) {
2727
proxy.Mux.HandleFunc("/", bt.ServeHTTP)
2828

2929
{
30-
res := g.Req("", proxy.URL("/test?q=ok"))
30+
// browser
31+
res := g.Req("", proxy.URL("/test?q=ok"), http.Header{"Accept-Language": {"en"}})
3132
g.Has(res.String(), "<body></body>")
3233
}
3334

3435
{
35-
res := g.Req("", proxy.URL("/test?q=ok"), http.Header{"Accept-Language": {"en"}})
36+
// web crawler
37+
res := g.Req("", proxy.URL("/test?q=ok"))
3638
g.Has(res.String(), "/test?q=ok")
3739
}
3840
}

0 commit comments

Comments
 (0)