transport/http: fix the setting of custom HTTP headers

This fixes a bug where the custom X-Goog headers (like request reason)
are only set if the User-Agent header is also set. Looking at the commit
history, it seems that User-Agent was the only custom header at one point
and the code would return early (in dial.go:112) if it was empty as an
optimization. This logic was not updated when more custom headers were
added, which introduced a bug.

Change-Id: I9b46655628bc682eddede14f02dcc871fec04bc6
Reviewed-on: https://code-review.googlesource.com/c/google-api-go-client/+/47932
Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Shin Fan <shinfan@google.com>
Reviewed-by: Chris Broadfoot <cbro@google.com>
diff --git a/transport/http/dial.go b/transport/http/dial.go
index 4a6af55..26c8d8a 100644
--- a/transport/http/dial.go
+++ b/transport/http/dial.go
@@ -109,16 +109,15 @@
 	if rt == nil {
 		return nil, errors.New("transport: no Transport specified")
 	}
-	if t.userAgent == "" {
-		return rt.RoundTrip(req)
-	}
 	newReq := *req
 	newReq.Header = make(http.Header)
 	for k, vv := range req.Header {
 		newReq.Header[k] = vv
 	}
-	// TODO(cbro): append to existing User-Agent header?
-	newReq.Header.Set("User-Agent", t.userAgent)
+	if t.userAgent != "" {
+		// TODO(cbro): append to existing User-Agent header?
+		newReq.Header.Set("User-Agent", t.userAgent)
+	}
 
 	// Attach system parameters into the header
 	if t.quotaProject != "" {