@@ -69,12 +69,11 @@ const (
6969 // which only does a single read per stream.
7070 defaultReadID = 1
7171
72- forceDirectConnectivityFallbackAllowed = "FALLBACK_ALLOWED"
73- forceDirectConnectivityEnforced = "ENFORCED"
74- forceDirectConnectivityOptedOut = "OPTED_OUT"
75- directConnectivityHeaderKey = "force_direct_connectivity"
76- requestParamsHeaderKey = "x-goog-request-params"
77- directPathEndpointPrefix = "google-c2p:///"
72+ forceDirectConnectivityEnforced = "ENFORCED"
73+ forceDirectConnectivityOptedOut = "OPTED_OUT"
74+ directConnectivityHeaderKey = "force_direct_connectivity"
75+ requestParamsHeaderKey = "x-goog-request-params"
76+ directPathEndpointPrefix = "google-c2p:///"
7877)
7978
8079// defaultGRPCOptions returns a set of the default client options
@@ -216,30 +215,31 @@ func (c *grpcStorageClient) prepareDirectPathMetadata(ctx context.Context, targe
216215 }
217216
218217 // Determine the intended mode based on user configuration.
219- value := forceDirectConnectivityFallbackAllowed // Default
218+ value := ""
220219 if c .config .grpcDirectPathEnforced {
221220 value = forceDirectConnectivityEnforced
222221 }
223222
224223 // Downgrade based on connection status.
225224 if ! isDirectPath {
226- // TODO: Reject call if set to ENFORCED when supported.
227225 // Downgrade to OPTED_OUT for server-side monitoring.
228226 value = forceDirectConnectivityOptedOut
229227 }
230228
231229 dc := directConnectivityHeaderKey + "=" + value
232230
233- // Inject header.
234231 md , ok := metadata .FromOutgoingContext (ctx )
235232 if ! ok {
236233 md = metadata.MD {}
237234 }
238235
239- if vals := md .Get (requestParamsHeaderKey ); len (vals ) > 0 {
240- md .Set (requestParamsHeaderKey , vals [0 ]+ "&" + dc )
241- } else {
242- md .Set (requestParamsHeaderKey , dc )
236+ // Inject the header only if we have a value to set.
237+ if value != "" {
238+ if vals := md .Get (requestParamsHeaderKey ); len (vals ) > 0 {
239+ md .Set (requestParamsHeaderKey , vals [0 ]+ "&" + dc )
240+ } else {
241+ md .Set (requestParamsHeaderKey , dc )
242+ }
243243 }
244244
245245 return metadata .NewOutgoingContext (ctx , md ), nil
0 commit comments