You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-mitmproxy/addon/mapper_test.go

42 lines
727 B
Go

2 years ago
package addon
import "testing"
func TestParser(t *testing.T) {
content := `
GET /index.html
Host: www.baidu.com
Accept: */*
hello world
HTTP/1.1 200
ok
`
2 years ago
p, err := newMapperParserFromString(content)
if err != nil {
t.Fatal(err)
}
2 years ago
f, err := p.parse()
if err != nil {
t.Fatal(err)
}
if f.Request.Method != "GET" {
t.Fatal("request method error")
}
if f.Request.URL.String() != "http://www.baidu.com/index.html" {
t.Fatal("request url error")
}
if f.Response.StatusCode != 200 {
t.Fatal("response status code error")
}
if string(f.Response.Body) != "ok" {
t.Fatal("response body error")
}
if f.Response.Header.Get("Content-Length") != "2" {
t.Fatal("response header content-length error")
}
}