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

Side by Side Diff: go/src/infra/libs/gitiles/priv_textRequest.go

Issue 662113003: Drover's back, baby! (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git/+/master
Patch Set: more tests and refactors Created 6 years, 1 month 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 | « go/src/infra/libs/gitiles/priv_objRequest.go ('k') | go/src/infra/libs/gitiles/statusError.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package gitiles
6
7 import (
8 "encoding/base64"
9 "io"
10 "io/ioutil"
11 "net/http"
12 )
13
14 // Private /////////////////////////////////////////////////////////////////////
15
16 // Types ///////////////////////////////////////////////////////////////////////
17
18 type textResult struct {
19 err error
20 data []byte
21 }
22
23 type textRequest struct {
24 urlPath string
25 resultChan chan<- textResult
26 }
27
28 // Member functions ////////////////////////////////////////////////////////////
29
30 func (t textRequest) URLPath() string { return t.urlPath + "?format=TEXT" }
31 func (t textRequest) Method() string { return "GET" }
32 func (t textRequest) Body() io.Reader { return nil }
33
34 func (t textRequest) internalProcess(rsp *http.Response, err error) ([]byte, err or) {
35 if err != nil {
36 return nil, err
37 }
38 return ioutil.ReadAll(base64.NewDecoder(base64.StdEncoding, rsp.Body))
39 }
40
41 func (t textRequest) Process(rsp *http.Response, err error) {
42 if data, err := t.internalProcess(rsp, err); err != nil {
43 t.resultChan <- textResult{err: err}
44 } else {
45 t.resultChan <- textResult{data: data}
46 }
47 }
OLDNEW
« no previous file with comments | « go/src/infra/libs/gitiles/priv_objRequest.go ('k') | go/src/infra/libs/gitiles/statusError.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698