Skip to content
Snippets Groups Projects
Select Git revision
  • 8d0128a7dbd0aa3cb6ba9ce2ffd50bfd2fb3d145
  • noblogs default
  • noblogs-5.7.1
  • upstream
  • noblogs-5.7
  • noblogs-5.6new
  • upstream5.5.1
  • noblogs28dic
  • upstream28dic
  • noblogs-5.5.1
  • noblogs-5.4.2
  • noblogs-5.4_seconda
  • noblogs-5.4
  • noblogs-7c
  • wp5.2.3p3
  • mergedbconf
  • noblogs-5.7.1
  • noblogs.5.7.0p1
  • noblogs-5.7.0
  • noblogs-5.6p3
  • noblogs5.6p2
  • noblogs-5.6p1
  • noblogs-5.6
  • noblogs-5.4.2p1
  • noblogs-5.4.2
  • noblogs-5.4.1
  • noblogs-5.4
  • noblogs-p5.4
  • noblogs-5.3.2p2
  • noblogs-5.3.2p1
  • noblogs-5.3.2
  • noblogs-5.3
  • noblogs-5.2.3p4
  • noblogs-5.2.3p3
  • noblogs-5.2.3p2
  • noblogs-5.2.3p1
36 results

jquery.privacysharebuttons.min.js

Blame
  • http.go 9.75 KiB
    // Copyright 2018 The Go Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style
    // license that can be found in the LICENSE file.
    
    package acme
    
    import (
    	"bytes"
    	"context"
    	"crypto"
    	"crypto/rand"
    	"encoding/json"
    	"errors"
    	"fmt"
    	"io"
    	"math/big"
    	"net/http"
    	"strconv"
    	"strings"
    	"time"
    )
    
    // retryTimer encapsulates common logic for retrying unsuccessful requests.
    // It is not safe for concurrent use.
    type retryTimer struct {
    	// backoffFn provides backoff delay sequence for retries.
    	// See Client.RetryBackoff doc comment.
    	backoffFn func(n int, r *http.Request, res *http.Response) time.Duration
    	// n is the current retry attempt.
    	n int
    }
    
    func (t *retryTimer) inc() {
    	t.n++
    }
    
    // backoff pauses the current goroutine as described in Client.RetryBackoff.
    func (t *retryTimer) backoff(ctx context.Context, r *http.Request, res *http.Response) error {
    	d := t.backoffFn(t.n, r, res)
    	if d <= 0 {
    		return fmt.Errorf("acme: no more retries for %s; tried %d time(s)", r.URL, t.n)
    	}
    	wakeup := time.NewTimer(d)
    	defer wakeup.Stop()
    	select {
    	case <-ctx.Done():
    		return ctx.Err()
    	case <-wakeup.C:
    		return nil
    	}
    }
    
    func (c *Client) retryTimer() *retryTimer {
    	f := c.RetryBackoff
    	if f == nil {
    		f = defaultBackoff
    	}
    	return &retryTimer{backoffFn: f}
    }
    
    // defaultBackoff provides default Client.RetryBackoff implementation
    // using a truncated exponential backoff algorithm,
    // as described in Client.RetryBackoff.
    //
    // The n argument is always bounded between 1 and 30.
    // The returned value is always greater than 0.
    func defaultBackoff(n int, r *http.Request, res *http.Response) time.Duration {
    	const max = 10 * time.Second
    	var jitter time.Duration
    	if x, err := rand.Int(rand.Reader, big.NewInt(1000)); err == nil {