Charset detection heuristics added with chardet lib.
This commit is contained in:
@@ -13,7 +13,6 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func TestSimple(t *testing.T) {
|
||||
@@ -175,33 +174,6 @@ func TestExtractor(t *testing.T) {
|
||||
}).Start()
|
||||
}
|
||||
|
||||
func TestCharsetDetection(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, "\xf0ültekin")
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
geziyor.NewGeziyor(&geziyor.Options{
|
||||
StartURLs: []string{ts.URL},
|
||||
ParseFunc: func(g *geziyor.Geziyor, r *client.Response) {
|
||||
if !utf8.Valid(r.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
},
|
||||
CharsetDetectDisabled: false,
|
||||
}).Start()
|
||||
|
||||
geziyor.NewGeziyor(&geziyor.Options{
|
||||
StartURLs: []string{ts.URL},
|
||||
ParseFunc: func(g *geziyor.Geziyor, r *client.Response) {
|
||||
if utf8.Valid(r.Body) {
|
||||
t.Fatal()
|
||||
}
|
||||
},
|
||||
CharsetDetectDisabled: true,
|
||||
}).Start()
|
||||
}
|
||||
|
||||
func TestRedirect(t *testing.T) {
|
||||
defer leaktest.Check(t)()
|
||||
geziyor.NewGeziyor(&geziyor.Options{
|
||||
|
||||
Reference in New Issue
Block a user