Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package prod | 5 package prod |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "net/http" | 9 "net/http" |
| 10 "net/http/cookiejar" | 10 "net/http/cookiejar" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 // | 107 // |
| 108 // * Otherwise, it will create a Google OAuth2 client with the following scope s: | 108 // * Otherwise, it will create a Google OAuth2 client with the following scope s: |
| 109 // - "https://www.googleapis.com/auth/appengine.apis" | 109 // - "https://www.googleapis.com/auth/appengine.apis" |
| 110 // - "https://www.googleapis.com/auth/userinfo.email" | 110 // - "https://www.googleapis.com/auth/userinfo.email" |
| 111 // - "https://www.googleapis.com/auth/cloud.platform" | 111 // - "https://www.googleapis.com/auth/cloud.platform" |
| 112 func UseRemote(inOutCtx *context.Context, host string, client *http.Client) (err error) { | 112 func UseRemote(inOutCtx *context.Context, host string, client *http.Client) (err error) { |
| 113 if client == nil { | 113 if client == nil { |
| 114 if strings.HasPrefix(host, "localhost") { | 114 if strings.HasPrefix(host, "localhost") { |
| 115 transp := http.DefaultTransport | 115 transp := http.DefaultTransport |
| 116 if aeCtx := AEContextNoTxn(*inOutCtx); aeCtx != nil { | 116 if aeCtx := AEContextNoTxn(*inOutCtx); aeCtx != nil { |
| 117 » » » » transp = urlfetch.Get(aeCtx) | 117 » » » » transp = urlfetch.Get(*inOutCtx) |
|
Vadim Sh.
2016/01/11 21:27:18
or you can use real URL fetch service with aeCtx.
| |
| 118 } | 118 } |
| 119 | 119 |
| 120 client = &http.Client{Transport: transp} | 120 client = &http.Client{Transport: transp} |
| 121 client.Jar, err = cookiejar.New(nil) | 121 client.Jar, err = cookiejar.New(nil) |
| 122 if err != nil { | 122 if err != nil { |
| 123 return | 123 return |
| 124 } | 124 } |
| 125 u := fmt.Sprintf("http://%s/_ah/login?%s", host, url.Val ues{ | 125 u := fmt.Sprintf("http://%s/_ah/login?%s", host, url.Val ues{ |
| 126 "email": {"admin@example.com"}, | 126 "email": {"admin@example.com"}, |
| 127 "admin": {"True"}, | 127 "admin": {"True"}, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 aeCtx, err := remote_api.NewRemoteContext(host, client) | 153 aeCtx, err := remote_api.NewRemoteContext(host, client) |
| 154 if err != nil { | 154 if err != nil { |
| 155 return | 155 return |
| 156 } | 156 } |
| 157 *inOutCtx = setupAECtx(*inOutCtx, aeCtx) | 157 *inOutCtx = setupAECtx(*inOutCtx, aeCtx) |
| 158 return nil | 158 return nil |
| 159 } | 159 } |
| OLD | NEW |