<commit_before>// Package request abstracts a client's request so that all middleware
// will handle them in an unified way.
package request

import (
	"net"
	"strings"

	"github.com/coredns/coredns/middleware/pkg/edns"

	"github.com/miekg/dns"
)

// Request contains some connection state and is useful in middleware.
type Request struct {
	Req *dns.Msg
	W   dns.ResponseWriter

	// Cache size after first call to Size or Do.
	size int
	do   int // 0: not, 1: true: 2: false
	// TODO(miek): opt record itself as well?

	// Cache lowercase qname.
	name string
}

// NewWithQuestion returns a new request based on the old, but with a new question
// section in the request.
func (r *Request) NewWithQuestion(name string, typ uint16) Request {
	req1 := Request{W: r.W, Req: r.Req.Copy()}
	req1.Req.Question[0] = dns.Question{Name: dns.Fqdn(name), Qclass: dns.ClassINET, Qtype: typ}
	return req1<commit_msg>core: add Zone in request.Request (#857)<commit_after>// Package request abstracts a client's request so that all middleware
// will handle them in an unified way.
package request

import (
	"net"
	"strings"

	"github.com/coredns/coredns/middleware/pkg/edns"

	"github.com/miekg/dns"
)

// Request contains some connection state and is useful in middleware.
type Request struct {
	Req *dns.Msg
	W   dns.ResponseWriter

	// Optional lowercased zone of this query.
	Zone string

	// Cache size after first call to Size or Do.
	size int
	do   int // 0: not, 1: true: 2: false
	// TODO(miek): opt record itself as well?

	// Cache lowercase qname.
	name string
}

// NewWithQuestion returns a new request based on the old, but with a new question
// section in the request.
func (r *Request) NewWithQuestion(name string, typ uint16) Request {
	req1 := Request{W: r.W, Req: r.Req.Copy()}
	req1.Req.Question[0] = dns.Question{Name: dns.Fqdn(name), Qclass: dns.ClassINET, Qtype: typ}
	return req1
{'fraction_non_alphanumeric': 0.10670892762810354, 'fraction_numerical': 0.011093502377179081, 'mean_word_length': 3.6195121951219513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5279347', 'n_tokens_mistral': 661, 'n_tokens_neox': 635, 'n_words': 236}