diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2016-10-08 16:02:50 -0500 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2016-10-08 16:02:50 -0500 |
commit | baf7141d1dd0f99d561a2197a909c66dd389809d (patch) | |
tree | 92c176f713b0b28893344261b1e567db5e30ba79 /vendor/google.golang.org/appengine/internal | |
parent | 696aebffe56853345d679d4d2b3051236423c6db (diff) |
Update dependencies
Diffstat (limited to 'vendor/google.golang.org/appengine/internal')
-rw-r--r-- | vendor/google.golang.org/appengine/internal/api.go | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/vendor/google.golang.org/appengine/internal/api.go b/vendor/google.golang.org/appengine/internal/api.go index ec5aa59..e9c56d4 100644 --- a/vendor/google.golang.org/appengine/internal/api.go +++ b/vendor/google.golang.org/appengine/internal/api.go @@ -60,6 +60,9 @@ var ( Dial: limitDial, }, } + + defaultTicketOnce sync.Once + defaultTicket string ) func apiURL() *url.URL { @@ -266,6 +269,19 @@ func WithContext(parent netcontext.Context, req *http.Request) netcontext.Contex return withContext(parent, c) } +func getDefaultTicket() string { + defaultTicketOnce.Do(func() { + appID := partitionlessAppID() + escAppID := strings.Replace(strings.Replace(appID, ":", "_", -1), ".", "_", -1) + majVersion := VersionID(nil) + if i := strings.Index(majVersion, "."); i > 0 { + majVersion = majVersion[:i] + } + defaultTicket = fmt.Sprintf("%s/%s.%s.%s", escAppID, ModuleName(nil), majVersion, InstanceID()) + }) + return defaultTicket +} + func BackgroundContext() netcontext.Context { ctxs.Lock() defer ctxs.Unlock() @@ -275,13 +291,7 @@ func BackgroundContext() netcontext.Context { } // Compute background security ticket. - appID := partitionlessAppID() - escAppID := strings.Replace(strings.Replace(appID, ":", "_", -1), ".", "_", -1) - majVersion := VersionID(nil) - if i := strings.Index(majVersion, "."); i > 0 { - majVersion = majVersion[:i] - } - ticket := fmt.Sprintf("%s/%s.%s.%s", escAppID, ModuleName(nil), majVersion, InstanceID()) + ticket := getDefaultTicket() ctxs.bg = &context{ req: &http.Request{ @@ -475,6 +485,10 @@ func Call(ctx netcontext.Context, service, method string, in, out proto.Message) } ticket := c.req.Header.Get(ticketHeader) + // Fall back to use background ticket when the request ticket is not available in Flex. + if ticket == "" { + ticket = getDefaultTicket() + } req := &remotepb.Request{ ServiceName: &service, Method: &method, |