-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strip context path correctly if deployed to the root context #731
Conversation
Thks @chkal. It sounds good to me. What do you think @LucasC, @garcia-jj? |
I use with root context and all paths works fine. Have you tested in which server? |
return uri; | ||
} | ||
return uri.substring(getContextPath().length()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should have here a method, on VRaptorRequest/MutableRequest, returning the request uri without the context path, so we don't duplicate this logic here and on DefaultStaticContentHandler. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But in that case we would need to cast that HttpServletRequest in DefaultStaticContentHandler, this could be problematic, right? But I agree that we should'nt duplicate this code, maybe we should create a component with this logic and inject it in both classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, not a good solution =/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
big enough for a component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its kind of overkill :-\
maybe we should leave as it is? create a static method (urgh)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the duplication =/ I prefer the static method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine for me :D
@chkal, what do you think? do you want to refactor that code extracting a static method and reuse it in both classes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on my phone and on vacation right now, so this will be short...
I had this issue with Undertow, which is the Servlet container of Wildfly.
And yeah, sure, I can refactor the patch. Creating a single static method
for this makes sense. I'll do this next week after returning from vacation.
Am 06.08.2014 21:17 schrieb "csokol" notifications@github.com:
In
vraptor-core/src/main/java/br/com/caelum/vraptor/http/VRaptorRequest.java:return uri.replaceFirst("(?i);jsessionid=.*$", ""); }
- private String stripContextPath(String uri) {
if ("/".equals(getContextPath())) {
return uri;
}
return uri.substring(getContextPath().length());
- }
Fine for me :D
@chkal https://github.com/chkal, what do you think? do you want to
refactor that code extracting a static method and reuse it in both classes?Reply to this email directly or view it on GitHub
https://github.com/caelum/vraptor4/pull/731/files#r15896613.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do this next week after returning from vacation.
thanks @chkal, enjoy your vacation's last week, we can wait for it :)
@garcia-jj, adding this change will break something in your case? |
I can test tonight.
|
I refactored the context path removal to a static method called I'm not sure if this is the best place for the method. But as we actually would like to have something as Any thoughts on this? |
Ups. Travis failed. Not sure if this is caused by my commit. I just merged the pull request with master locally and it builds fine. |
@@ -63,10 +65,10 @@ public boolean requestingStaticFile(HttpServletRequest request) throws Malformed | |||
} | |||
|
|||
private String uriRelativeToContextRoot(HttpServletRequest request) { | |||
String uri = request.getRequestURI().substring(request.getContextPath().length()); | |||
String uri = VRaptorRequest.stripContextPath(request.getContextPath(), request.getRequestURI()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about changing to stripContextPath(request)
?
So stripContextPath
ask for contextPath
and requestURI
internally.
I'm ok with method place too. |
Hey @Turini, yeah, I agree. That's much nicer. I also renamed the method to What do you think? |
Sounds good. I like it. |
great @chkal, thanks! |
Strip context path correctly if deployed to the root context
You're welcome. And thank YOU for this awesome framework. :) |
@Turini, since we are getting some false warnings by Travis, can you run Thank you :) |
@garcia-jj already done, its working (I'll restart Travis build). |
all green now :) |
VRaptor is currently not stripping the context path correctly if the app is deployed to the root context path.
For ordinary context paths like
/myapp
it works fine:But for the root context path
/
it is not correct:This pull request fixes the problem. I hope I found all the relevant places. :)