All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.doudou.common.tool.utils.BrowserUtils Maven / Gradle / Ivy

There is a newer version: 1.3.2
Show newest version
package top.doudou.common.tool.utils;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;

@Slf4j
public class BrowserUtils {

    public static boolean isBrowser(HttpServletRequest request){
        String userAgent = request.getHeader("User-Agent");
        if(StringUtils.isNotBlank(userAgent) && userAgent.startsWith("Mozilla/5.0")){
            return true;
        }
        String accept = request.getHeader("Accept");
        if(StringUtils.isNotBlank(accept) && accept.startsWith("text/html")){
            return true;
        }
        return false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy