Mercurial Hosting > luan
comparison src/org/eclipse/jetty/server/Response.java @ 809:09d518d313b7
remove SessionManager
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Thu, 08 Sep 2016 16:38:30 -0600 |
| parents | 3428c60d7cfc |
| children | f8f7cb485c25 |
comparison
equal
deleted
inserted
replaced
| 808:b3176fd168bf | 809:09d518d313b7 |
|---|---|
| 185 /* | 185 /* |
| 186 * @see javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String) | 186 * @see javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String) |
| 187 */ | 187 */ |
| 188 public String encodeURL(String url) | 188 public String encodeURL(String url) |
| 189 { | 189 { |
| 190 final Request request=_connection.getRequest(); | 190 throw new UnsupportedOperationException(); |
| 191 SessionManager sessionManager = request.getSessionManager(); | |
| 192 if (sessionManager==null) | |
| 193 return url; | |
| 194 | |
| 195 HttpURI uri = null; | |
| 196 if (sessionManager.isCheckingRemoteSessionIdEncoding() && URIUtil.hasScheme(url)) | |
| 197 { | |
| 198 uri = new HttpURI(url); | |
| 199 String path = uri.getPath(); | |
| 200 path = (path == null?"":path); | |
| 201 int port=uri.getPort(); | |
| 202 if (port<0) | |
| 203 port = HttpSchemes.HTTPS.equalsIgnoreCase(uri.getScheme())?443:80; | |
| 204 if (!request.getServerName().equalsIgnoreCase(uri.getHost()) || | |
| 205 request.getServerPort()!=port || | |
| 206 !path.startsWith(request.getContextPath())) //TODO the root context path is "", with which every non null string starts | |
| 207 return url; | |
| 208 } | |
| 209 | |
| 210 String sessionURLPrefix = sessionManager.getSessionIdPathParameterNamePrefix(); | |
| 211 if (sessionURLPrefix==null) | |
| 212 return url; | |
| 213 | |
| 214 if (url==null) | |
| 215 return null; | |
| 216 | |
| 217 // should not encode if cookies in evidence | |
| 218 if ((sessionManager.isUsingCookies() && request.isRequestedSessionIdFromCookie()) || !sessionManager.isUsingURLs()) | |
| 219 { | |
| 220 int prefix=url.indexOf(sessionURLPrefix); | |
| 221 if (prefix!=-1) | |
| 222 { | |
| 223 int suffix=url.indexOf("?",prefix); | |
| 224 if (suffix<0) | |
| 225 suffix=url.indexOf("#",prefix); | |
| 226 | |
| 227 if (suffix<=prefix) | |
| 228 return url.substring(0,prefix); | |
| 229 return url.substring(0,prefix)+url.substring(suffix); | |
| 230 } | |
| 231 return url; | |
| 232 } | |
| 233 | |
| 234 // get session; | |
| 235 HttpSession session=request.getSession(false); | |
| 236 | |
| 237 // no session | |
| 238 if (session == null) | |
| 239 return url; | |
| 240 | |
| 241 // invalid session | |
| 242 if (!sessionManager.isValid(session)) | |
| 243 return url; | |
| 244 | |
| 245 String id=sessionManager.getNodeId(session); | |
| 246 | |
| 247 if (uri == null) | |
| 248 uri = new HttpURI(url); | |
| 249 | |
| 250 | |
| 251 // Already encoded | |
| 252 int prefix=url.indexOf(sessionURLPrefix); | |
| 253 if (prefix!=-1) | |
| 254 { | |
| 255 int suffix=url.indexOf("?",prefix); | |
| 256 if (suffix<0) | |
| 257 suffix=url.indexOf("#",prefix); | |
| 258 | |
| 259 if (suffix<=prefix) | |
| 260 return url.substring(0,prefix+sessionURLPrefix.length())+id; | |
| 261 return url.substring(0,prefix+sessionURLPrefix.length())+id+ | |
| 262 url.substring(suffix); | |
| 263 } | |
| 264 | |
| 265 // edit the session | |
| 266 int suffix=url.indexOf('?'); | |
| 267 if (suffix<0) | |
| 268 suffix=url.indexOf('#'); | |
| 269 if (suffix<0) | |
| 270 { | |
| 271 return url+ | |
| 272 ((HttpSchemes.HTTPS.equalsIgnoreCase(uri.getScheme()) || HttpSchemes.HTTP.equalsIgnoreCase(uri.getScheme())) && uri.getPath()==null?"/":"") + //if no path, insert the root path | |
| 273 sessionURLPrefix+id; | |
| 274 } | |
| 275 | |
| 276 | |
| 277 return url.substring(0,suffix)+ | |
| 278 ((HttpSchemes.HTTPS.equalsIgnoreCase(uri.getScheme()) || HttpSchemes.HTTP.equalsIgnoreCase(uri.getScheme())) && uri.getPath()==null?"/":"")+ //if no path so insert the root path | |
| 279 sessionURLPrefix+id+url.substring(suffix); | |
| 280 } | 191 } |
| 281 | 192 |
| 282 /* ------------------------------------------------------------ */ | 193 /* ------------------------------------------------------------ */ |
| 283 /** | 194 /** |
| 284 * @see javax.servlet.http.HttpServletResponse#encodeRedirectURL(java.lang.String) | 195 * @see javax.servlet.http.HttpServletResponse#encodeRedirectURL(java.lang.String) |
