mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Rename context_→ctx.
This commit is contained in:
parent
ff34e01e9c
commit
7662ccb00c
1 changed files with 7 additions and 7 deletions
|
@ -20,7 +20,7 @@ const (
|
||||||
urlFetchTimeout = 20 * time.Second
|
urlFetchTimeout = 20 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
var context_ context.Context
|
var ctx context.Context
|
||||||
|
|
||||||
// Join two URL paths.
|
// Join two URL paths.
|
||||||
func pathJoin(a, b string) string {
|
func pathJoin(a, b string) string {
|
||||||
|
@ -67,26 +67,26 @@ func copyRequest(r *http.Request) (*http.Request, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func handler(w http.ResponseWriter, r *http.Request) {
|
func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
context_ = appengine.NewContext(r)
|
ctx = appengine.NewContext(r)
|
||||||
fr, err := copyRequest(r)
|
fr, err := copyRequest(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf(context_, "copyRequest: %s", err)
|
log.Errorf(ctx, "copyRequest: %s", err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if urlFetchTimeout != 0 {
|
if urlFetchTimeout != 0 {
|
||||||
var cancel context.CancelFunc
|
var cancel context.CancelFunc
|
||||||
context_, cancel = context.WithTimeout(context_, urlFetchTimeout)
|
ctx, cancel = context.WithTimeout(ctx, urlFetchTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
}
|
}
|
||||||
// Use urlfetch.Transport directly instead of urlfetch.Client because we
|
// Use urlfetch.Transport directly instead of urlfetch.Client because we
|
||||||
// want only a single HTTP transaction, not following redirects.
|
// want only a single HTTP transaction, not following redirects.
|
||||||
transport := urlfetch.Transport{
|
transport := urlfetch.Transport{
|
||||||
Context: context_,
|
Context: ctx,
|
||||||
}
|
}
|
||||||
resp, err := transport.RoundTrip(fr)
|
resp, err := transport.RoundTrip(fr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf(context_, "RoundTrip: %s", err)
|
log.Errorf(ctx, "RoundTrip: %s", err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(resp.StatusCode)
|
w.WriteHeader(resp.StatusCode)
|
||||||
n, err := io.Copy(w, resp.Body)
|
n, err := io.Copy(w, resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf(context_, "io.Copy after %d bytes: %s", n, err)
|
log.Errorf(ctx, "io.Copy after %d bytes: %s", n, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue