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

Unified Diff: common/gcloud/gs/opts.go

Issue 1844253002: Fix GS client breakage, remove offset hacks. (Closed) Base URL: https://github.com/luci/luci-go@subscriber-update
Patch Set: Created 4 years, 9 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 | « common/gcloud/gs/gs.go ('k') | server/logdog/storage/archive/storage.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/gcloud/gs/opts.go
diff --git a/common/gcloud/gs/opts.go b/common/gcloud/gs/opts.go
deleted file mode 100644
index 171d52d5c04ad159e826cfa48a7be3a27b961054..0000000000000000000000000000000000000000
--- a/common/gcloud/gs/opts.go
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2015 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 gs
-
-import (
- "fmt"
- "net/http"
-)
-
-// Options are the set of extra options to apply to the Google Storage request.
-type Options struct {
- // From is the range request starting index. If >0, the beginning of the
- // range request will be set.
- From int64
- // To is the range request ending index. If >0, the end of the
- // range request will be set.
- //
- // If no From index is set, this will result in a request indexed from the end
- // of the object.
- To int64
-}
-
-// gsRoundTripper is an http.RoundTripper implementation that allows us to
-// inject some HTTP headers. It is necessary because the stock Google Storage
-// API doesn't allow access to specific header manipulation.
-//
-// https://cloud.google.com/storage/docs/reference-headers#range
-type gsRoundTripper struct {
- http.RoundTripper
- *Options
-}
-
-func (rt *gsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
- if req.Header == nil {
- req.Header = make(http.Header)
- }
-
- // Add Range header, if configured.
- rh := ""
- switch {
- case rt.From > 0 && rt.To > 0:
- rh = fmt.Sprintf("bytes=%d-%d", rt.From, rt.To)
-
- case rt.From > 0:
- rh = fmt.Sprintf("bytes=%d-", rt.From)
-
- case rt.To > 0:
- rh = fmt.Sprintf("bytes=-%d", rt.To)
- }
- if rh != "" {
- req.Header.Add("Range", rh)
- }
-
- return rt.RoundTripper.RoundTrip(req)
-}
« no previous file with comments | « common/gcloud/gs/gs.go ('k') | server/logdog/storage/archive/storage.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698