context: allow nil request context in fetch cases

This commit is contained in:
WeebDataHoarder
2025-05-02 02:23:48 +02:00
parent 61d0964eb0
commit a2225fe749
2 changed files with 6 additions and 3 deletions

View File

@@ -24,7 +24,11 @@ type requestDataContextKey struct {
}
func RequestDataFromContext(ctx context.Context) *RequestData {
return ctx.Value(requestDataContextKey{}).(*RequestData)
val := ctx.Value(requestDataContextKey{})
if val == nil {
return nil
}
return val.(*RequestData)
}
type RequestId [16]byte

View File

@@ -116,8 +116,7 @@ func (b Backend) Create() (*httputil.ReverseProxy, error) {
}
if !b.Transparent {
data := challenge.RequestDataFromContext(req.Context())
if data != nil {
if data := challenge.RequestDataFromContext(req.Context()); data != nil {
data.RequestHeaders(req.Header)
}
}