From 912ce69a64aa84511af7cef997fc3e336810b587 Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Wed, 16 Dec 2020 16:53:37 -0500 Subject: internal/worker: honor proxyfetch query param If the fetch handler sees the "proxyfetch" query param set to "off", it tells internal/fetch to disable fetching by the proxy. Change-Id: I1c9303f96f9249a5b420a73451551aba21d9d417 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/278953 Trust: Jonathan Amsterdam Run-TryBot: Jonathan Amsterdam TryBot-Result: kokoro Reviewed-by: Jamal Carvalho --- internal/queue/queue.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'internal/queue/queue.go') diff --git a/internal/queue/queue.go b/internal/queue/queue.go index 03578d12..5890b11d 100644 --- a/internal/queue/queue.go +++ b/internal/queue/queue.go @@ -137,11 +137,16 @@ func (q *GCP) ScheduleFetch(ctx context.Context, modulePath, version, suffix str // See https://cloud.google.com/tasks/docs/creating-http-target-tasks. const maxCloudTasksTimeout = 30 * time.Minute +const ( + DisableProxyFetchParam = "proxyfetch" + DisableProxyFetchValue = "off" +) + func (q *GCP) newTaskRequest(modulePath, version, suffix string, disableProxyFetch bool) *taskspb.CreateTaskRequest { taskID := newTaskID(modulePath, version) relativeURI := fmt.Sprintf("/fetch/%s/@v/%s", modulePath, version) if disableProxyFetch { - relativeURI += "?proxyfetch=off" + relativeURI += fmt.Sprintf("?%s=%s", DisableProxyFetchParam, DisableProxyFetchValue) } task := &taskspb.Task{ Name: fmt.Sprintf("%s/tasks/%s", q.queueName, taskID), -- cgit v1.3-6-g1900