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

Unified 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, 2 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/libs/gitiles/priv_textRequest.go
diff --git a/go/src/infra/libs/gitiles/priv_textRequest.go b/go/src/infra/libs/gitiles/priv_textRequest.go
new file mode 100644
index 0000000000000000000000000000000000000000..da6a9a446f5dcbdb3fa0140a6e45f3d0df5a007f
--- /dev/null
+++ b/go/src/infra/libs/gitiles/priv_textRequest.go
@@ -0,0 +1,47 @@
+// Copyright 2014 The Chromium 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 gitiles
+
+import (
+ "encoding/base64"
+ "io"
+ "io/ioutil"
+ "net/http"
+)
+
+// Private /////////////////////////////////////////////////////////////////////
+
+// Types ///////////////////////////////////////////////////////////////////////
+
+type textResult struct {
+ err error
+ data []byte
+}
+
+type textRequest struct {
+ urlPath string
+ resultChan chan<- textResult
+}
+
+// Member functions ////////////////////////////////////////////////////////////
+
+func (t textRequest) URLPath() string { return t.urlPath + "?format=TEXT" }
+func (t textRequest) Method() string { return "GET" }
+func (t textRequest) Body() io.Reader { return nil }
+
+func (t textRequest) internalProcess(rsp *http.Response, err error) ([]byte, error) {
+ if err != nil {
+ return nil, err
+ }
+ return ioutil.ReadAll(base64.NewDecoder(base64.StdEncoding, rsp.Body))
+}
+
+func (t textRequest) Process(rsp *http.Response, err error) {
+ if data, err := t.internalProcess(rsp, err); err != nil {
+ t.resultChan <- textResult{err: err}
+ } else {
+ t.resultChan <- textResult{data: data}
+ }
+}
« 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