mirror of
https://github.com/zhigang1992/graphql-engine.git
synced 2026-05-25 18:32:23 +08:00
committed by
Alexis King
parent
3cad1319c4
commit
ffeda35ff7
@@ -366,9 +366,10 @@ execRemoteGQ reqId userInfo reqHdrs q rsi opDef = do
|
||||
let confHdrs = map (\(k, v) -> (CI.mk $ CS.cs k, CS.cs v)) hdrs
|
||||
clientHdrs = bool [] filteredHeaders fwdClientHdrs
|
||||
-- filter out duplicate headers
|
||||
-- priority: conf headers > resolved userinfo vars > client headers
|
||||
-- priority: conf headers > resolved userinfo vars > x-forwarded headers > client headers
|
||||
hdrMaps = [ Map.fromList confHdrs
|
||||
, Map.fromList userInfoToHdrs
|
||||
, Map.fromList xForwardedHeaders
|
||||
, Map.fromList clientHdrs
|
||||
]
|
||||
headers = Map.toList $ foldr Map.union Map.empty hdrMaps
|
||||
@@ -400,6 +401,12 @@ execRemoteGQ reqId userInfo reqHdrs q rsi opDef = do
|
||||
userInfoToList userInfo
|
||||
filteredHeaders = filterUserVars $ filterRequestHeaders reqHdrs
|
||||
|
||||
xForwardedHeaders = flip mapMaybe reqHdrs $ \(hdrName, hdrValue) ->
|
||||
case hdrName of
|
||||
"Host" -> Just ("X-Forwarded-Host", hdrValue)
|
||||
"User-Agent" -> Just ("X-Forwarded-User-Agent", hdrValue)
|
||||
_ -> Nothing
|
||||
|
||||
filterUserVars hdrs =
|
||||
let txHdrs = map (\(n, v) -> (bsToTxt $ CI.original n, bsToTxt v)) hdrs
|
||||
in map (\(k, v) -> (CI.mk $ CS.cs k, CS.cs v)) $
|
||||
|
||||
Reference in New Issue
Block a user