Skip to content

Commit

Permalink
Merge pull request #35 from pugwoo/develop-fix-jakarta
Browse files Browse the repository at this point in the history
release 1.2.4
  • Loading branch information
pugwoo authored Nov 3, 2023
2 parents 80e3ae6 + fcb1d1b commit 6983fa3
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2023年11月3日
v1.2.4 - [fix] 修复因同时支持javax.servlet-api和jakarta.servlet-api而导致方法使用时,缺少任何一个包会编译报错的问题

2023年11月2日
v1.2.3 - [enhance] 因为同时需要支持javax.servlet-api和jakarta.servlet-api,故引入两者api

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<dependency>
<groupId>com.pugwoo</groupId>
<artifactId>woo-utils</artifactId>
<version>1.2.3</version>
<version>1.2.4</version>
</dependency>
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.pugwoo</groupId>
<artifactId>woo-utils</artifactId>
<packaging>jar</packaging>
<version>1.2.3</version>
<version>1.2.4</version>

<name>woo-utils</name>
<description>the common utils</description>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/pugwoo/wooutils/net/Browser.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void addRequestHeader(HttpServletRequest request) {
* 设置HttpServletRequest的所有头部信息
* @param request HttpServletRequest
*/
public void addRequestHeader(jakarta.servlet.http.HttpServletRequest request) {
public void addRequestHeaderForJakarta(jakarta.servlet.http.HttpServletRequest request) {
Enumeration<String> headerNames = request.getHeaderNames();
while(headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/pugwoo/wooutils/net/CookieUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static String getCookieValue(HttpServletRequest request, String name) {
* @param name
* @return
*/
public static String getCookieValue(jakarta.servlet.http.HttpServletRequest request, String name) {
public static String getCookieValueForJakarta(jakarta.servlet.http.HttpServletRequest request, String name) {
if(name == null) {
return null;
}
Expand Down Expand Up @@ -108,7 +108,7 @@ public static List<String> getCookieValues(HttpServletRequest request, String na
* @param name
* @return
*/
public static List<String> getCookieValues(jakarta.servlet.http.HttpServletRequest request, String name) {
public static List<String> getCookieValuesForJakarta(jakarta.servlet.http.HttpServletRequest request, String name) {
if(name == null) {
return null;
}
Expand Down Expand Up @@ -167,7 +167,7 @@ public static void addCookie(HttpServletResponse response, String name, String v
* @param domain 指定域名,null表示不指定
* @param expireSeconds cookie生命周期 以秒为单位,当设置为0时,cookie默认有效期10年;如果删除,请用removeCookie方法
*/
public static void addCookie(jakarta.servlet.http.HttpServletResponse response, String name, String value,
public static void addCookieForJakarta(jakarta.servlet.http.HttpServletResponse response, String name, String value,
String domain, int expireSeconds) {
try {
value = value == null ? null : URLEncoder.encode(value, "UTF-8");
Expand Down Expand Up @@ -208,9 +208,9 @@ public static void addCookie(HttpServletResponse response, String name, String v
* @param value
* @param domain
*/
public static void addCookie(jakarta.servlet.http.HttpServletResponse response, String name, String value,
public static void addCookieForJakarta(jakarta.servlet.http.HttpServletResponse response, String name, String value,
String domain) {
addCookie(response, name, value, domain, 0);
addCookieForJakarta(response, name, value, domain, 0);
}

/**
Expand All @@ -235,7 +235,7 @@ public static void removeCookie(HttpServletResponse response, String name, Strin
* @param name
* @param domain 当为null时表示不指定
*/
public static void removeCookie(jakarta.servlet.http.HttpServletResponse response, String name, String domain) {
public static void removeCookieForJakarta(jakarta.servlet.http.HttpServletResponse response, String name, String domain) {
jakarta.servlet.http.Cookie cookie = new jakarta.servlet.http.Cookie(name, "");
cookie.setPath("/");
if(domain != null) {
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/pugwoo/wooutils/net/NetUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static String getRemoteIp(HttpServletRequest request) {
* 获得客户端的ip地址,请配合nginx配置使用
* @return 可能返回多个ip,以逗号分隔
*/
public static String getRemoteIp(jakarta.servlet.http.HttpServletRequest request) {
public static String getRemoteIpForJakarta(jakarta.servlet.http.HttpServletRequest request) {
String ip = request.getHeader("X-Forwarded-For");
if(StringTools.isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
Expand Down Expand Up @@ -101,7 +101,7 @@ public static boolean isWeixinBrowser(HttpServletRequest request) {
* @param request
* @return
*/
public static boolean isWeixinBrowser(jakarta.servlet.http.HttpServletRequest request) {
public static boolean isWeixinBrowserForJakarta(jakarta.servlet.http.HttpServletRequest request) {
String userAgent = request.getHeader("user-agent");
if(userAgent != null && userAgent.toLowerCase().contains("micromessenger")) {
return true;
Expand All @@ -127,7 +127,7 @@ public static boolean isMobileBrowser(HttpServletRequest request) {
* @param request
* @return
*/
public static boolean isMobileBrowser(jakarta.servlet.http.HttpServletRequest request) {
public static boolean isMobileBrowserForJakarta(jakarta.servlet.http.HttpServletRequest request) {
String userAgent = request.getHeader("user-agent");
if(userAgent != null && userAgent.contains("Mobile")) {
return true;
Expand All @@ -152,7 +152,7 @@ public static String getHttpRootURL(HttpServletRequest request) {
* @param request
* @return 例如http://www.abc.com,不带根/
*/
public static String getHttpRootURL(jakarta.servlet.http.HttpServletRequest request) {
public static String getHttpRootURLForJakarta(jakarta.servlet.http.HttpServletRequest request) {
return request.getScheme() + "://" + request.getServerName()
+ ("http".equalsIgnoreCase(request.getScheme()) && request.getServerPort() == 80
|| "https".equalsIgnoreCase(request.getScheme()) && request.getServerPort() == 443 ? ""
Expand All @@ -173,7 +173,7 @@ public static String getHostname(HttpServletRequest request) {
* @param request
* @return
*/
public static String getHostname(jakarta.servlet.http.HttpServletRequest request) {
public static String getHostnameForJakarta(jakarta.servlet.http.HttpServletRequest request) {
return request.getServerName();
}

Expand All @@ -193,7 +193,7 @@ public static String getHostnameWithPort(HttpServletRequest request) {
* @param request
* @return
*/
public static String getHostnameWithPort(jakarta.servlet.http.HttpServletRequest request) {
public static String getHostnameWithPortForJakarta(jakarta.servlet.http.HttpServletRequest request) {
return request.getServerName() + ":" + request.getServerPort();
}

Expand All @@ -214,8 +214,8 @@ public static String getFullUrlWithParam(HttpServletRequest request) {
* @param request
* @return
*/
public static String getFullUrlWithParam(jakarta.servlet.http.HttpServletRequest request) {
String domain = getHttpRootURL(request);
public static String getFullUrlWithParamForJakarta(jakarta.servlet.http.HttpServletRequest request) {
String domain = getHttpRootURLForJakarta(request);
String path = request.getRequestURI();
String queryString = request.getQueryString();
return domain + path + (queryString == null ? "" : "?" + queryString);
Expand All @@ -235,7 +235,7 @@ public static String getUrlPath(HttpServletRequest request) {
* @param request
* @return
*/
public static String getUrlPath(jakarta.servlet.http.HttpServletRequest request) {
public static String getUrlPathForJakarta(jakarta.servlet.http.HttpServletRequest request) {
return request.getRequestURI();
}

Expand Down Expand Up @@ -306,7 +306,7 @@ public static String getContextPath(HttpServletRequest request) {
* @param request
* @return
*/
public static String getContextPath(jakarta.servlet.http.HttpServletRequest request) {
public static String getContextPathForJakarta(jakarta.servlet.http.HttpServletRequest request) {
return request.getContextPath();
}
}

0 comments on commit 6983fa3

Please sign in to comment.