From 11acecce926e45f2ec37d0908d104edf014b4539 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 10 Oct 2011 18:04:20 -0700 Subject: [PATCH] Start of making canLongPoll configurable for App Engine to set it to false, for now. Change-Id: Ib4d7a306276a7292e7d8a8838c3b026d38b5fb6b --- lib/go/camli/blobserver/handlers/stat.go | 6 +++++- lib/go/camli/blobserver/interface.go | 11 ++++++----- lib/go/camli/serverconfig/serverconfig.go | 12 ++++++++---- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/go/camli/blobserver/handlers/stat.go b/lib/go/camli/blobserver/handlers/stat.go index 7bd1fdde1..4f255f568 100644 --- a/lib/go/camli/blobserver/handlers/stat.go +++ b/lib/go/camli/blobserver/handlers/stat.go @@ -117,7 +117,11 @@ func handleStat(conn http.ResponseWriter, req *http.Request, storage blobserver. configer, _ := storage.(blobserver.Configer) ret := commonUploadResponse(configer, req) + if configer != nil { + ret["canLongPoll"] = true + } else { + ret["canLongPoll"] = configer.Config().CanLongPoll + } ret["stat"] = statRes - ret["canLongPoll"] = true httputil.ReturnJson(conn, ret) } diff --git a/lib/go/camli/blobserver/interface.go b/lib/go/camli/blobserver/interface.go index 4a93fdb19..749f4fd27 100644 --- a/lib/go/camli/blobserver/interface.go +++ b/lib/go/camli/blobserver/interface.go @@ -39,8 +39,8 @@ type BlobStatter interface { // waitSeconds is the max time to wait for the blobs to exist, // or 0 for no delay. StatBlobs(dest chan<- blobref.SizedBlobRef, - blobs []*blobref.BlobRef, - waitSeconds int) os.Error + blobs []*blobref.BlobRef, + waitSeconds int) os.Error } type StatReceiver interface { @@ -75,9 +75,9 @@ type BlobEnumerator interface { // after and waitSeconds can't be used together. One must be // its zero value. EnumerateBlobs(dest chan<- blobref.SizedBlobRef, - after string, - limit uint, - waitSeconds int) os.Error + after string, + limit uint, + waitSeconds int) os.Error } // Cache is the minimal interface expected of a blob cache. @@ -95,6 +95,7 @@ type BlobReceiveConfiger interface { type Config struct { Writable, Readable bool IsQueue bool // supports deletes + CanLongPoll bool // the "http://host:port" and optional path (but without trailing slash) to have "/camli/*" appended URLBase string diff --git a/lib/go/camli/serverconfig/serverconfig.go b/lib/go/camli/serverconfig/serverconfig.go index 818d58106..d3ac2d382 100644 --- a/lib/go/camli/serverconfig/serverconfig.go +++ b/lib/go/camli/serverconfig/serverconfig.go @@ -118,13 +118,17 @@ func makeCamliHandler(prefix, baseURL string, storage blobserver.Storage) http.H } baseURL = strings.TrimRight(baseURL, "/") + canLongPoll := true + // TODO(bradfitz): set to false if this is App Engine, or provide some way to disable + storageConfig := &storageAndConfig{ storage, &blobserver.Config{ - Writable: true, - Readable: true, - IsQueue: false, - URLBase: baseURL + prefix[:len(prefix)-1], + Writable: true, + Readable: true, + IsQueue: false, + URLBase: baseURL + prefix[:len(prefix)-1], + CanLongPoll: canLongPoll, }, } return http.HandlerFunc(func(conn http.ResponseWriter, req *http.Request) {