WangHan
2024-09-12 d5855a4926926698b740bc6c7ba489de47adb68b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package tech.powerjob.server.auth.common.utils;
 
import tech.powerjob.common.OmsConstant;
 
import javax.servlet.http.HttpServletRequest;
 
/**
 * HttpServletUtils
 *
 * @author tjq
 * @since 2024/2/12
 */
public class HttpServletUtils {
 
    public static String fetchFromHeader(String key, HttpServletRequest httpServletRequest) {
        // header、cookie 都能获取
        String v = httpServletRequest.getHeader(key);
 
        // 解决 window.localStorage.getItem 为 null 的问题
        if (OmsConstant.NULL.equalsIgnoreCase(v) || "undefined".equalsIgnoreCase(v)) {
            return null;
        }
 
        return v;
    }
 
}