client: httpClient -> simpleHTTPClient

This commit is contained in:
Brian Waldon 2015-01-26 17:08:43 -08:00 committed by Yicheng Qin
parent f037cb9f65
commit 3f5e827e3c
2 changed files with 13 additions and 13 deletions

View File

@ -39,7 +39,7 @@ var (
func defaultHTTPClientFactory(tr CancelableTransport, ep url.URL) HTTPClient {
return &redirectFollowingHTTPClient{
max: DefaultMaxRedirects,
client: &httpClient{
client: &simpleHTTPClient{
transport: tr,
endpoint: ep,
},
@ -181,12 +181,12 @@ type roundTripResponse struct {
err error
}
type httpClient struct {
type simpleHTTPClient struct {
transport CancelableTransport
endpoint url.URL
}
func (c *httpClient) Do(ctx context.Context, act HTTPAction) (*http.Response, []byte, error) {
func (c *simpleHTTPClient) Do(ctx context.Context, act HTTPAction) (*http.Response, []byte, error) {
req := act.HTTPRequest(c.endpoint)
rtchan := make(chan roundTripResponse, 1)

View File

@ -109,9 +109,9 @@ func (a *fakeAction) HTTPRequest(url.URL) *http.Request {
return &http.Request{}
}
func TestHTTPClientDoSuccess(t *testing.T) {
func TestSimpleHTTPClientDoSuccess(t *testing.T) {
tr := newFakeTransport()
c := &httpClient{transport: tr}
c := &simpleHTTPClient{transport: tr}
tr.respchan <- &http.Response{
StatusCode: http.StatusTeapot,
@ -134,9 +134,9 @@ func TestHTTPClientDoSuccess(t *testing.T) {
}
}
func TestHTTPClientDoError(t *testing.T) {
func TestSimpleHTTPClientDoError(t *testing.T) {
tr := newFakeTransport()
c := &httpClient{transport: tr}
c := &simpleHTTPClient{transport: tr}
tr.errchan <- errors.New("fixture")
@ -146,9 +146,9 @@ func TestHTTPClientDoError(t *testing.T) {
}
}
func TestHTTPClientDoCancelContext(t *testing.T) {
func TestSimpleHTTPClientDoCancelContext(t *testing.T) {
tr := newFakeTransport()
c := &httpClient{transport: tr}
c := &simpleHTTPClient{transport: tr}
tr.startCancel <- struct{}{}
tr.finishCancel <- struct{}{}
@ -159,9 +159,9 @@ func TestHTTPClientDoCancelContext(t *testing.T) {
}
}
func TestHTTPClientDoCancelContextWaitForRoundTrip(t *testing.T) {
func TestSimpleHTTPClientDoCancelContextWaitForRoundTrip(t *testing.T) {
tr := newFakeTransport()
c := &httpClient{transport: tr}
c := &simpleHTTPClient{transport: tr}
donechan := make(chan struct{})
ctx, cancel := context.WithCancel(context.Background())
@ -175,7 +175,7 @@ func TestHTTPClientDoCancelContextWaitForRoundTrip(t *testing.T) {
select {
case <-donechan:
t.Fatalf("httpClient.do should not have exited yet")
t.Fatalf("simpleHTTPClient.Do should not have exited yet")
default:
}
@ -186,7 +186,7 @@ func TestHTTPClientDoCancelContextWaitForRoundTrip(t *testing.T) {
//expected behavior
return
case <-time.After(time.Second):
t.Fatalf("httpClient.do did not exit within 1s")
t.Fatalf("simpleHTTPClient.Do did not exit within 1s")
}
}