cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject cxf git commit: Remove use of deprecated classes in netty-server
Date Mon, 13 Feb 2017 17:37:55 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 7eb2d58fa -> c783e60a8


Remove use of deprecated classes in netty-server


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/c783e60a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/c783e60a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/c783e60a

Branch: refs/heads/master
Commit: c783e60a8bcea76b9fecb75364b120d39c8ea28a
Parents: 7eb2d58
Author: Daniel Kulp <dkulp@apache.org>
Authored: Mon Feb 13 12:37:29 2017 -0500
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Mon Feb 13 12:37:29 2017 -0500

----------------------------------------------------------------------
 .../interceptor/HttpSessionInterceptor.java     |  8 +++---
 .../server/servlet/NettyHttpServletRequest.java | 16 +++++------
 .../server/servlet/NettyServletResponse.java    |  9 -------
 .../transport/http/netty/server/util/Utils.java | 28 ++++----------------
 4 files changed, 16 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c783e60a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/interceptor/HttpSessionInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/interceptor/HttpSessionInterceptor.java
b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/interceptor/HttpSessionInterceptor.java
index 414514b..1579379 100644
--- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/interceptor/HttpSessionInterceptor.java
+++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/interceptor/HttpSessionInterceptor.java
@@ -26,12 +26,12 @@ import org.apache.cxf.transport.http.netty.server.servlet.NettyHttpSession;
 import org.apache.cxf.transport.http.netty.server.session.HttpSessionStore;
 import org.apache.cxf.transport.http.netty.server.util.Utils;
 import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.http.ClientCookieEncoder;
-import io.netty.handler.codec.http.Cookie;
 import io.netty.handler.codec.http.HttpHeaders;
 import io.netty.handler.codec.http.HttpHeaders.Names;
 import io.netty.handler.codec.http.HttpRequest;
 import io.netty.handler.codec.http.HttpResponse;
+import io.netty.handler.codec.http.cookie.ClientCookieEncoder;
+import io.netty.handler.codec.http.cookie.Cookie;
 
 public class HttpSessionInterceptor implements NettyInterceptor {
     private boolean sessionRequestedByCookie;
@@ -49,7 +49,7 @@ public class HttpSessionInterceptor implements NettyInterceptor {
                 NettyHttpSession.SESSION_ID_KEY, request);
         if (cookies != null) {
             for (Cookie cookie : cookies) {
-                String jsessionId = cookie.getValue();
+                String jsessionId = cookie.value();
                 NettyHttpSession s = HttpSessionThreadLocal.getSessionStore()
                         .findSession(jsessionId);
                 if (s != null) {
@@ -69,7 +69,7 @@ public class HttpSessionInterceptor implements NettyInterceptor {
         if (s != null && !this.sessionRequestedByCookie) {
             // setup the Cookie for session
             HttpHeaders.addHeader(response, Names.SET_COOKIE,  
-                                  ClientCookieEncoder.encode(NettyHttpSession.SESSION_ID_KEY,
s.getId()));
+                                  ClientCookieEncoder.STRICT.encode(NettyHttpSession.SESSION_ID_KEY,
s.getId()));
         }
 
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/c783e60a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java
b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java
index 08bce14b..61285ab 100644
--- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java
+++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java
@@ -44,12 +44,12 @@ import javax.servlet.http.HttpSession;
 
 import org.apache.cxf.transport.http.netty.server.util.Utils;
 import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.http.CookieDecoder;
 import io.netty.handler.codec.http.HttpContent;
 import io.netty.handler.codec.http.HttpHeaders;
 import io.netty.handler.codec.http.HttpHeaders.Names;
 import io.netty.handler.codec.http.HttpRequest;
 import io.netty.handler.codec.http.QueryStringDecoder;
+import io.netty.handler.codec.http.cookie.ServerCookieDecoder;
 import io.netty.handler.ssl.SslHandler;
 
 import static io.netty.handler.codec.http.HttpHeaders.Names.COOKIE;
@@ -116,18 +116,16 @@ public class NettyHttpServletRequest implements HttpServletRequest {
     public Cookie[] getCookies() {
         String cookieString = this.originalRequest.headers().get(COOKIE);
         if (cookieString != null) {
-            Set<io.netty.handler.codec.http.Cookie> cookies = CookieDecoder.decode(cookieString);
+            Set<io.netty.handler.codec.http.cookie.Cookie> cookies = ServerCookieDecoder.STRICT.decode(cookieString);
             if (!cookies.isEmpty()) {
                 Cookie[] cookiesArray = new Cookie[cookies.size()];
                 int indx = 0;
-                for (io.netty.handler.codec.http.Cookie c : cookies) {
-                    Cookie cookie = new Cookie(c.getName(), c.getValue());
-                    cookie.setComment(c.getComment());
-                    cookie.setDomain(c.getDomain());
-                    cookie.setMaxAge((int)c.getMaxAge());
-                    cookie.setPath(c.getPath());
+                for (io.netty.handler.codec.http.cookie.Cookie c : cookies) {
+                    Cookie cookie = new Cookie(c.name(), c.value());
+                    cookie.setDomain(c.domain());
+                    cookie.setMaxAge((int)c.maxAge());
+                    cookie.setPath(c.path());
                     cookie.setSecure(c.isSecure());
-                    cookie.setVersion(c.getVersion());
                     cookiesArray[indx] = cookie;
                     indx++;
                 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/c783e60a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyServletResponse.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyServletResponse.java
b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyServletResponse.java
index 22540f2..96f8813 100644
--- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyServletResponse.java
+++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyServletResponse.java
@@ -28,15 +28,12 @@ import java.util.Locale;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 
-import io.netty.handler.codec.http.ClientCookieEncoder;
-import io.netty.handler.codec.http.Cookie;
 import io.netty.handler.codec.http.HttpContent;
 import io.netty.handler.codec.http.HttpHeaders;
 import io.netty.handler.codec.http.HttpResponse;
 import io.netty.handler.codec.http.HttpResponseStatus;
 
 import static io.netty.handler.codec.http.HttpHeaders.Names.LOCATION;
-import static io.netty.handler.codec.http.HttpHeaders.Names.SET_COOKIE;
 
 
 public class NettyServletResponse implements HttpServletResponse {
@@ -59,12 +56,6 @@ public class NettyServletResponse implements HttpServletResponse {
         return originalResponse;
     }
 
-    public void addCookie(Cookie cookie) {
-        HttpHeaders.addHeader(this.originalResponse, 
-                              SET_COOKIE, 
-                              ClientCookieEncoder.encode(cookie.getName(), cookie.getValue()));
-    }
-
     public void addDateHeader(String name, long date) {
         HttpHeaders.addHeader(this.originalResponse, name, date);
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/c783e60a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/util/Utils.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/util/Utils.java
b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/util/Utils.java
index 5623736..1f55c19 100644
--- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/util/Utils.java
+++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/util/Utils.java
@@ -34,10 +34,9 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
-import io.netty.handler.codec.http.Cookie;
-import io.netty.handler.codec.http.CookieDecoder;
 import io.netty.handler.codec.http.HttpRequest;
-import io.netty.handler.codec.http.HttpResponse;
+import io.netty.handler.codec.http.cookie.Cookie;
+import io.netty.handler.codec.http.cookie.ServerCookieDecoder;
 
 import static io.netty.handler.codec.http.HttpHeaders.Names.COOKIE;
 
@@ -104,30 +103,13 @@ public final class Utils {
     }
 
     public static Collection<Cookie> getCookies(String name,
-                                                      HttpRequest request) {
+                                                HttpRequest request) {
         String cookieString = request.headers().get(COOKIE);
         if (cookieString != null) {
             List<Cookie> foundCookie = new ArrayList<>();
-            Set<Cookie> cookies = CookieDecoder.decode(cookieString);
+            Set<Cookie> cookies = ServerCookieDecoder.STRICT.decode(cookieString);
             for (Cookie cookie : cookies) {
-                if (cookie.getName().equals(name)) {
-                    foundCookie.add(cookie);
-                }
-            }
-
-            return foundCookie;
-        }
-        return null;
-    }
-
-    public static Collection<Cookie> getCookies(String name,
-                                                HttpResponse response) {
-        String cookieString = response.headers().get(COOKIE);
-        if (cookieString != null) {
-            List<Cookie> foundCookie = new ArrayList<>();
-            Set<Cookie> cookies = CookieDecoder.decode(cookieString);
-            for (Cookie cookie : cookies) {
-                if (cookie.getName().equals(name)) {
+                if (cookie.name().equals(name)) {
                     foundCookie.add(cookie);
                 }
             }


Mime
View raw message