Merge branch 'master' of github.com:miekg/dns

This commit is contained in:
Miek Gieben 2013-07-25 09:30:42 +00:00
commit 10ad5a45e2
2 changed files with 14 additions and 1 deletions

View File

@ -168,10 +168,15 @@ func (mux *ServeMux) match(q string, t uint16) Handler {
mux.m.RLock()
defer mux.m.RUnlock()
var handler Handler
b := make([]byte, len(q)) // worst case, one label of length q
off := 0
end := false
for {
if h, ok := mux.z[q[off:]]; ok {
l := len(q[off:])
for i := 0; i < l; i++ {
b[i] = q[off+i] | ( 'a' - 'A')
}
if h, ok := mux.z[string(b[:l])]; ok { // 'causes garbage, might want to change the map key
if t != TypeDS {
return h
} else {

View File

@ -55,6 +55,14 @@ func TestServing(t *testing.T) {
t.Log("Unexpected result for example.com", txt, "!= Hello example")
t.Fail()
}
// Test Mixes cased as notices by Ask.
m.SetQuestion("eXaMplE.cOm.", TypeTXT)
r, _, _ = c.Exchange(m, "127.0.0.1:8053")
txt = r.Extra[0].(*TXT).Txt[0]
if txt != "Hello example" {
t.Log("Unexpected result for example.com", txt, "!= Hello example")
t.Fail()
}
}
func BenchmarkServing(b *testing.B) {