@@ -371,29 +371,31 @@ func (req *Request) FastlyMeta() (*FastlyMeta, error) {
371371 SandboxRequests : req .sandboxRequests ,
372372 }
373373
374- fastlyMeta .RequestID , err = req .downstream .req .DownstreamRequestID ()
375- if err != nil {
376- return nil , fmt .Errorf ("get request ID: %w" , err )
377- }
374+ if req .downstream .req != nil {
375+ fastlyMeta .RequestID , err = req .downstream .req .DownstreamRequestID ()
376+ if err != nil {
377+ return nil , fmt .Errorf ("get request ID: %w" , err )
378+ }
378379
379- fastlyMeta .H2 , err = req .downstream .req .DownstreamH2Fingerprint ()
380- if err = ignoreNoneError (err ); err != nil {
381- return nil , fmt .Errorf ("get H2 fingerprint: %w" , err )
382- }
380+ fastlyMeta .H2 , err = req .downstream .req .DownstreamH2Fingerprint ()
381+ if err = ignoreNoneError (err ); err != nil {
382+ return nil , fmt .Errorf ("get H2 fingerprint: %w" , err )
383+ }
383384
384- fastlyMeta .OH , err = req .downstream .req .DownstreamOHFingerprint ()
385- if err = ignoreNoneError (err ); err != nil {
386- return nil , fmt .Errorf ("get OH fingerprint: %w" , err )
387- }
385+ fastlyMeta .OH , err = req .downstream .req .DownstreamOHFingerprint ()
386+ if err = ignoreNoneError (err ); err != nil {
387+ return nil , fmt .Errorf ("get OH fingerprint: %w" , err )
388+ }
388389
389- fastlyMeta .DDOSDetected , err = req .downstream .req .DownstreamDDOSDetected ()
390- if err != nil {
391- return nil , fmt .Errorf ("get ddos detected: %w" , err )
392- }
390+ fastlyMeta .DDOSDetected , err = req .downstream .req .DownstreamDDOSDetected ()
391+ if err != nil {
392+ return nil , fmt .Errorf ("get ddos detected: %w" , err )
393+ }
393394
394- fastlyMeta .FastlyKeyIsValid , err = req .downstream .req .DownstreamFastlyKeyIsValid ()
395- if err != nil {
396- return nil , fmt .Errorf ("get fastly key is valid: %w" , err )
395+ fastlyMeta .FastlyKeyIsValid , err = req .downstream .req .DownstreamFastlyKeyIsValid ()
396+ if err != nil {
397+ return nil , fmt .Errorf ("get fastly key is valid: %w" , err )
398+ }
397399 }
398400
399401 req .fastlyMeta = fastlyMeta
@@ -563,7 +565,6 @@ func (req *Request) sendToImageOpto(ctx context.Context, backend string) (*Respo
563565 abiResp , abiBody , err := req .abi .req .SendToImageOpto (req .abi .body , backend , query )
564566 if err != nil {
565567 return nil , err
566-
567568 }
568569
569570 resp , err := newResponse (req , backend , abiResp , abiBody )
@@ -1053,15 +1054,17 @@ func (req *Request) TLSClientCertificateInfo() (*TLSClientCertificateInfo, error
10531054 var err error
10541055 var cert TLSClientCertificateInfo
10551056
1056- cert .RawClientCertificate , err = req .downstream .req .DownstreamTLSRawClientCertificate ()
1057- if err = ignoreNoneError (err ); err != nil {
1058- return nil , fmt .Errorf ("get TLS raw client certificate: %w" , err )
1059- }
1057+ if req .downstream .req != nil {
1058+ cert .RawClientCertificate , err = req .downstream .req .DownstreamTLSRawClientCertificate ()
1059+ if err = ignoreNoneError (err ); err != nil {
1060+ return nil , fmt .Errorf ("get TLS raw client certificate: %w" , err )
1061+ }
10601062
1061- if cert .RawClientCertificate != nil {
1062- cert .ClientCertIsVerified , err = req .downstream .req .DownstreamTLSClientCertVerifyResult ()
1063- if err != nil {
1064- return nil , fmt .Errorf ("get TLS client certificate verify: %w" , err )
1063+ if cert .RawClientCertificate != nil {
1064+ cert .ClientCertIsVerified , err = req .downstream .req .DownstreamTLSClientCertVerifyResult ()
1065+ if err != nil {
1066+ return nil , fmt .Errorf ("get TLS client certificate verify: %w" , err )
1067+ }
10651068 }
10661069 }
10671070
@@ -1115,6 +1118,8 @@ type DecompressResponseOptions struct {
11151118 Gzip bool
11161119}
11171120
1121+ var ErrHandoffNotSupported = errors .New ("handoff not supported on this request" )
1122+
11181123// HandoffWebsocket passes the WebSocket directly to a backend.
11191124//
11201125// This can only be used on services that have the WebSockets feature
@@ -1124,6 +1129,9 @@ type DecompressResponseOptions struct {
11241129// Once this method has been called, no other response can be sent to this
11251130// request, and the application can exit without affecting the send.
11261131func (r * Request ) HandoffWebsocket (backend string ) error {
1132+ if r .downstream .req == nil {
1133+ return ErrHandoffNotSupported
1134+ }
11271135 return r .downstream .req .HandoffWebsocket (backend )
11281136}
11291137
@@ -1136,7 +1144,10 @@ func (r *Request) HandoffWebsocket(backend string) error {
11361144// called, no other response can be sent to this request, and the
11371145// application can exit without affecting the send.
11381146func (r * Request ) HandoffFanout (backend string ) error {
1139- return r .downstream .req .HandoffWebsocket (backend )
1147+ if r .downstream .req == nil {
1148+ return ErrHandoffNotSupported
1149+ }
1150+ return r .downstream .req .HandoffFanout (backend )
11401151}
11411152
11421153// nopCloser is functionally the same as io.NopCloser, except that we
0 commit comments