func (c *dohConn) Write(b []byte) (n int, err error) {
	return c.inBuffer.Write(b)
}
Write only writes the bytes to send in the connection
to a buffer. The HTTP request is made in Read instead
such that response data can be read at the same time.
package doh
import (
	"bytes"
	"context"
	"net"
	"net/http"
	"net/url"
	"sync"
	"time"
)
func newDoHConn(ctx context.Context, client *http.Client,
	bufferPool *sync.Pool, dohURL *url.URL) net.Conn {
	ctx, cancel := context.WithCancel(ctx)
	const maxUDPSize = 4096
	return &dohConn{
		ctx:        ctx,
		client:     client,
		bufferPool: bufferPool,
		dohURL:     dohURL,
		inBuffer:   bytes.NewBuffer(make([]byte, 0, maxUDPSize)),
		outBuffer:  bytes.NewBuffer(make([]byte, 0, maxUDPSize)),
		cancel:     cancel,
	}
}
type dohConn struct {
	ctx        context.Context
	client     *http.Client
	bufferPool *sync.Pool
	dohURL     *url.URL
	inBuffer  *bytes.Buffer  
	outBuffer *bytes.Buffer  
	cancel    context.CancelFunc
	deadline  time.Time
}
func (c *dohConn) readOutputBuffer(b []byte) (n int, err error) {
	if c.outBuffer.Len() == 0 {
		return 0, nil
	}
	return c.outBuffer.Read(b)
}
func (c *dohConn) Read(b []byte) (n int, err error) {
	n, err = c.readOutputBuffer(b)
	if err != nil {
		return n, err
	} else if n > 0 {
		return n, nil
	}
	dnsQueryBytes := c.inBuffer.Bytes()
	dnsQueryBytes = dnsQueryBytes[2:]
	c.ctx, c.cancel = context.WithCancel(c.ctx)
	c.ctx, c.cancel = context.WithDeadline(c.ctx, c.deadline)
	dnsAnswerBytes, err := dohHTTPRequest(c.ctx, c.client, c.bufferPool, c.dohURL, dnsQueryBytes)
	c.cancel()
	if err != nil {
		return 0, err
	}
	if err := c.writeToOutputBuffer(dnsAnswerBytes); err != nil {
		return 0, err
	}
	return c.outBuffer.Read(b)
}