// Nonce is an endpoint for getting a fresh nonce with an HTTP GET or HEAD
// request. This endpoint only returns a status code header - the `HandleFunc`
// wrapper ensures that a nonce is written in the correct response header.
500696
func (wfe *WebFrontEndImpl) Nonce(
	ctx context.Context,
	logEvent *web.RequestEvent,
	response http.ResponseWriter,
	request *http.Request) {
	statusCode := http.StatusNoContent
	// The ACME specification says GET requets should receive http.StatusNoContent
	// and HEAD requests should receive http.StatusOK. We gate this with the
	// HeadNonceStatusOK feature flag because it may break clients that are
	// programmed to expect StatusOK.
	if features.Enabled(features.HeadNonceStatusOK) && request.Method == "HEAD" {
		statusCode = http.StatusOK
	}
	response.WriteHeader(statusCode)
}
512656
func checkAcceptFromNonce(accept, nonce []byte) bool {
	if len(accept) != acceptSize {
		return false
	}
	// NOTE: expect does not escapes.
	expect := make([]byte, acceptSize)
	initAcceptFromNonce(expect, nonce)
	return bytes.Equal(expect, accept)
}
1120429
func (s *Signer) GenerateNonce(timestamp int64, args ...interface{}) string {
	str := fmt.Sprint(args...)
	str = fmt.Sprintf("%s%d", str, timestamp)
	hash := sha1.New()
	return fmt.Sprintf("%x", hash.Sum([]byte(str)))
}
25695
func (r *Router) HandleFunc(path string, h http.HandlerFunc, ms ...Method) {
	r.Route(
		path,
		func(w http.ResponseWriter, req *Request) error {
			h(w, req.Request)
			return nil
		},
		ms...,
	)
}
1086054
func (c *httpClient) getNoFollow(url string) (*http.Response, error) {
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return nil, err
	}
	for k, vs := range c.header {
		req.Header[k] = vs
	}
	t := c.client.Transport
	if t == nil {
		t = http.DefaultTransport
	}
	resp, err := t.RoundTrip(req)
	if err != nil {
		return nil, &RemoteError{req.URL.Host, err}
	}
	return resp, err
}
405523
func (sm *ServeMux) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request) error) {
	sm.ServeMux.Handle(pattern, sm.HandlerFunc(handler))
}
1027545
func (m *Mux) HandleFuncC(p Pattern, h func(context.Context, http.ResponseWriter, *http.Request)) {
	m.HandleC(p, HandlerFunc(h))
}
842838
func EncodeNonce(i uint64) BlockNonce {
	var n BlockNonce
	binary.BigEndian.PutUint64(n[:], i)
	return n
}
537187
func (f HandlerFuncC) ServeHTTPC(ctx context.Context, w http.ResponseWriter, r *http.Request) {
	f(ctx, w, r)
}
840657
func (s *Job) SetNonce(v string) *Job {
	s.Nonce = &v
	return s
}
377272
func (s *ThirdPartyJobDetails) SetNonce(v string) *ThirdPartyJobDetails {
	s.Nonce = &v
	return s
}
838993
func (c *Client) NoOp() (err error) {
	// Variants: NoOp
	// Request : MUST NOT key, value, extras
	// Response: MUST NOT key, value, extras
	m := &msg{
		header: header{
			Op: opNoop,
		},
	}

	for _, s := range c.servers {
		if s.isAlive {
			err = s.perform(m)
		}
	}
	return err // retrns err from last perform but maybe should handle differently
}
893080
func initNonce(dst []byte) {
	// NOTE: bts does not escapes.
	bts := make([]byte, nonceKeySize)
	if _, err := rand.Read(bts); err != nil {
		panic(fmt.Sprintf("rand read error: %s", err))
	}
	base64.StdEncoding.Encode(dst, bts)
}
1360311
func NewWithParamsAsyncFactoryNonce(params *Parameters, async AsynchronousFactory, nonce utils.NonceGenerator) *Client {
	c := &Client{
		asyncFactory:   async,
		Authentication: NoAuthentication,
		factories:      make(map[string]messageFactory),
		subscriptions:  newSubscriptions(params.HeartbeatTimeout, params.Logger),
		orderbooks:     make(map[string]*Orderbook),
		nonce:          nonce,
		isConnected:    false,
		parameters:     params,
		listener:       make(chan interface{}),
		terminal:       false,
		resetWebsocket: make(chan bool),
		shutdown:       make(chan bool),
		asynchronous:   async.Create(),
		log:            params.Logger,
	}
	c.registerPublicFactories()
	return c
}
584758
func (res *Resolver) HandleNonMesos(fwd exchanger.Forwarder) func(
	dns.ResponseWriter, *dns.Msg) {
	return func(w dns.ResponseWriter, r *dns.Msg) {
		logging.CurLog.NonMesosRequests.Inc()
		m, err := fwd(r, w.RemoteAddr().Network())
		if err != nil {
			m = new(dns.Msg).SetRcode(r, rcode(err))
		} else if len(m.Answer) == 0 {
			logging.CurLog.NonMesosNXDomain.Inc()
		}
		reply(w, m, res.config.SetTruncateBit)
	}
}
120650
func newNonce24() (*nonce24, error) {
	prefix, err := libkb.RandBytes(20)
	if err != nil {
		return nil, err
	}
	return &nonce24{prefix: prefix}, nil
}
1113152
func (mux *ServeMux) HandleOnce(m Matcher, h Handler) {
	mux.handle(&muxEntry{m, h, true})
}