internal: for Flex, use req.Context instead of a context map

This has the effect of removing support for Go 1.6 for Flex.

DO NOT SUBMIT
diff --git a/aetest/instance_vm.go b/aetest/instance_vm.go
index f9c18d3..b36beb2 100644
--- a/aetest/instance_vm.go
+++ b/aetest/instance_vm.go
@@ -17,7 +17,6 @@
 	"regexp"
 	"time"
 
-	"golang.org/x/net/context"
 	"google.golang.org/appengine/internal"
 )
 
@@ -69,13 +68,10 @@
 	if err != nil {
 		return nil, err
 	}
+	req = req.WithContext(internal.WithAppIDOverride(req.Context(), "dev~"+i.appID))
 
 	// Associate this request.
-	release := internal.RegisterTestRequest(req, i.apiURL, func(ctx context.Context) context.Context {
-		ctx = internal.WithAppIDOverride(ctx, "dev~"+i.appID)
-		return ctx
-	})
-	i.relFuncs = append(i.relFuncs, release)
+	req = internal.RegisterTestRequest(req, i.apiURL)
 
 	return req, nil
 }
diff --git a/internal/api.go b/internal/api.go
index efee060..312042b 100644
--- a/internal/api.go
+++ b/internal/api.go
@@ -83,20 +83,14 @@
 
 func handleHTTP(w http.ResponseWriter, r *http.Request) {
 	c := &context{
-		req:       r,
 		outHeader: w.Header(),
 		apiURL:    apiURL(),
+		req:       r,
 	}
-	stopFlushing := make(chan int)
+	r = r.WithContext(withContext(r.Context(), c))
+	c.req = r
 
-	ctxs.Lock()
-	ctxs.m[r] = c
-	ctxs.Unlock()
-	defer func() {
-		ctxs.Lock()
-		delete(ctxs.m, r)
-		ctxs.Unlock()
-	}()
+	stopFlushing := make(chan int)
 
 	// Patch up RemoteAddr so it looks reasonable.
 	if addr := r.Header.Get(userIPHeader); addr != "" {
@@ -197,15 +191,8 @@
 
 var ctxs = struct {
 	sync.Mutex
-	m  map[*http.Request]*context
 	bg *context // background context, lazily initialized
-	// dec is used by tests to decorate the netcontext.Context returned
-	// for a given request. This allows tests to add overrides (such as
-	// WithAppIDOverride) to the context. The map is nil outside tests.
-	dec map[*http.Request]func(netcontext.Context) netcontext.Context
-}{
-	m: make(map[*http.Request]*context),
-}
+}{}
 
 // context represents the context of an in-flight HTTP request.
 // It implements the appengine.Context and http.ResponseWriter interfaces.
@@ -254,22 +241,7 @@
 }
 
 func WithContext(parent netcontext.Context, req *http.Request) netcontext.Context {
-	ctxs.Lock()
-	c := ctxs.m[req]
-	d := ctxs.dec[req]
-	ctxs.Unlock()
-
-	if d != nil {
-		parent = d(parent)
-	}
-
-	if c == nil {
-		// Someone passed in an http.Request that is not in-flight.
-		// We panic here rather than panicking at a later point
-		// so that stack traces will be more sensible.
-		log.Panic("appengine: NewContext passed an unknown http.Request")
-	}
-	return withContext(parent, c)
+	return withContext(parent, fromContext(req.Context()))
 }
 
 // DefaultTicket returns a ticket used for background context or dev_appserver.
@@ -320,31 +292,14 @@
 // any API calls are sent to the provided URL. It returns a closure to delete
 // the registration.
 // It should only be used by aetest package.
-func RegisterTestRequest(req *http.Request, apiURL *url.URL, decorate func(netcontext.Context) netcontext.Context) func() {
+func RegisterTestRequest(req *http.Request, apiURL *url.URL) *http.Request {
 	c := &context{
-		req:    req,
 		apiURL: apiURL,
+		req:    req,
 	}
-	ctxs.Lock()
-	defer ctxs.Unlock()
-	if _, ok := ctxs.m[req]; ok {
-		log.Panic("req already associated with context")
-	}
-	if _, ok := ctxs.dec[req]; ok {
-		log.Panic("req already associated with context")
-	}
-	if ctxs.dec == nil {
-		ctxs.dec = make(map[*http.Request]func(netcontext.Context) netcontext.Context)
-	}
-	ctxs.m[req] = c
-	ctxs.dec[req] = decorate
-
-	return func() {
-		ctxs.Lock()
-		delete(ctxs.m, req)
-		delete(ctxs.dec, req)
-		ctxs.Unlock()
-	}
+	req = req.WithContext(withContext(req.Context(), c))
+	c.req = req
+	return req
 }
 
 var errTimeout = &CallError{