Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: common/lhttp/client.go

Issue 1159563002: Move retry and lhttp packages from client/internal to common/. (Closed) Base URL: git@github.com:luci/luci-go@master
Patch Set: move-retry-http Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/swarming/swarming.go ('k') | common/lhttp/client_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package lhttp 5 package lhttp
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/json" 9 "encoding/json"
10 "errors" 10 "errors"
11 "fmt" 11 "fmt"
12 "io" 12 "io"
13 "io/ioutil" 13 "io/ioutil"
14 "net/http" 14 "net/http"
15 "net/url" 15 "net/url"
16 "os" 16 "os"
17 "strings" 17 "strings"
18 18
19 » "github.com/luci/luci-go/client/internal/retry" 19 » "github.com/luci/luci-go/common/retry"
20 ) 20 )
21 21
22 // Handler is called once or multiple times for each HTTP request that is tried. 22 // Handler is called once or multiple times for each HTTP request that is tried.
23 type Handler func(*http.Response) error 23 type Handler func(*http.Response) error
24 24
25 // Retriable is a retry.Retriable that exposes the resulting HTTP status 25 // Retriable is a retry.Retriable that exposes the resulting HTTP status
26 // code. 26 // code.
27 type Retriable interface { 27 type Retriable interface {
28 retry.Retriable 28 retry.Retriable
29 // Returns the HTTP status code of the last request, if set. 29 // Returns the HTTP status code of the last request, if set.
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return fmt.Errorf("http request failed: %s (HTTP %d)", http.Stat usText(resp.StatusCode), resp.StatusCode) 182 return fmt.Errorf("http request failed: %s (HTTP %d)", http.Stat usText(resp.StatusCode), resp.StatusCode)
183 } 183 }
184 // The handler may still return a retry.Error to indicate that the reque st 184 // The handler may still return a retry.Error to indicate that the reque st
185 // should be retried even on successful status code. 185 // should be retried even on successful status code.
186 return r.handler(resp) 186 return r.handler(resp)
187 } 187 }
188 188
189 func (r *retriable) Status() int { 189 func (r *retriable) Status() int {
190 return r.status 190 return r.status
191 } 191 }
OLDNEW
« no previous file with comments | « client/swarming/swarming.go ('k') | common/lhttp/client_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698