You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Marat (JIRA)" <ji...@apache.org> on 2015/03/18 15:54:38 UTC
[jira] [Comment Edited] (CXF-6302) JAXRS issue with encoding in URL
[ https://issues.apache.org/jira/browse/CXF-6302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14367226#comment-14367226 ]
Marat edited comment on CXF-6302 at 3/18/15 2:53 PM:
-----------------------------------------------------
We are create a server via JAXRSServerFactoryBean for each actual service, because we dynamically deploy and undeploy services. When server was created "/REST/Test%20Test/Test%20Test" was used as address. So, method address will be "/Test%20Test/Test%20Test/Hello", becase we always use @Path("/") in interface.
This line returns null, because pathInfo is "/REST/Test Test/Test Test/Hello", but server was registered as "/REST/Test%20Test/Test%20Test". And can't find destination with URL + METHOD NAME in map.
I don't undestand where this code trim method path from URL
{code}
public AbstractHTTPDestination getDestinationForPath(String path, boolean tryDecoding) {
// to use the url context match
String m = getTrimmedPath(path);
AbstractHTTPDestination s = destinations.get(m);
if (s == null) {
s = decodedDestinations.get(m);
}
return s;
}
public String getTrimmedPath(String path) {
if (path == null) {
return "/";
}
final String lh = "http://localhost/";
final String lhs = "https://localhost/";
if (path.startsWith(lh)) {
path = path.substring(lh.length());
} else if (path.startsWith(lhs)) {
path = path.substring(lhs.length());
}
if (!path.contains("://") && !path.startsWith("/")) {
path = "/" + path;
}
return path;
}
{code}
was (Author: mkamalov):
We are create a server via JAXRSServerFactoryBean for each actual service, because we dynamically deploy and undeploy services. When server was created "/REST/Test%20Test/Test%20Test" was used as address. So, method address will be "/Test%20Test/Test%20Test/Hello".
This line returns null, because pathInfo is "/REST/Test Test/Test Test/Hello", but server was registered as "/REST/Test%20Test/Test%20Test". And can't find destination with URL + METHOD NAME in map.
I don't undestand where this code trim method path from URL
{code}
public AbstractHTTPDestination getDestinationForPath(String path, boolean tryDecoding) {
// to use the url context match
String m = getTrimmedPath(path);
AbstractHTTPDestination s = destinations.get(m);
if (s == null) {
s = decodedDestinations.get(m);
}
return s;
}
public String getTrimmedPath(String path) {
if (path == null) {
return "/";
}
final String lh = "http://localhost/";
final String lhs = "https://localhost/";
if (path.startsWith(lh)) {
path = path.substring(lh.length());
} else if (path.startsWith(lhs)) {
path = path.substring(lhs.length());
}
if (!path.contains("://") && !path.startsWith("/")) {
path = "/" + path;
}
return path;
}
{code}
> JAXRS issue with encoding in URL
> --------------------------------
>
> Key: CXF-6302
> URL: https://issues.apache.org/jira/browse/CXF-6302
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 3.0.3
> Reporter: Marat
> Priority: Minor
> Original Estimate: 4h
> Remaining Estimate: 4h
>
> I use url "/Test%20Test/Test%20Test" that define while create server via JAXRSServerFactoryBean. And I have error "No service was found." for my URL.
> I found that class org.apache.cxf.transport.http.DestinationRegistryImpl has decoding logic for SOAP requests, but Restful requests skip this logic. Please, chec checkRestfulRequest method in this class. Thsi method doesn't use decodedDestinations map for search.
> {code:title=DestinationRegistryImpl.java|borderStyle=solid}
> for (String path : getDestinationsPaths()) {
> String thePath = path.length() > 1 && path.endsWith(SLASH)
> ? path.substring(0, path.length() - 1) : path;
> if ((address.equals(thePath)
> || SLASH.equals(thePath)
> || (address.length() &gr; thePath.length()
> && address.startsWith(thePath) && address.charAt(thePath.length()) == '/'))
> && thePath.length() &gr; len) {
> ret = getDestinationForPath(path);
> len = path.length();
> }
> }
> {code}
> The thePath variable contains "/Test Test/Test Test", but i registered my service with URL "/Test%20Test/Test%20Test", so equals is false.
> Please, could you fix this issue. It is critical for us, because our URL can contains whitespaces.
> Thank you.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)