You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by antalus <fr...@gmail.com> on 2011/03/14 09:44:01 UTC

JAX-RS: %3B in Path Parameter results in 404 response

Hi,

I have a simple resource class

@Path("{id}")
public class TestResource {
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public Response test(@PathParam("id") String id){
        final String result = String.format("Received PathParam: '%s'", id);
        System.out.println(result);
        return Response.ok().entity(result).build();
    }
}

When I do the GET request with path "/hello%3B" the response is:

HTTP/1.1 404 Not Found
Content-Type: text/xml
Allow: GET,OPTIONS,HEAD
Date: Sun, 13 Mar 2011 08:17:40 GMT
Content-Length: 0
Server: Jetty(6.1.26)

But what I expect from this request is that method test() is invoked with
"hello;" string as parameter.
So I think the problem is with encoded semi-colon %3B. Other encoded special
symbols seem to work as expected. 

Is such behavior a bug?

Environment:
CXF 2.3.3
JDK 6 update 24
Jetty 6.1.26 (via Maven plugin)


--
View this message in context: http://cxf.547215.n5.nabble.com/JAX-RS-3B-in-Path-Parameter-results-in-404-response-tp3556009p3556009.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: JAX-RS: %3B in Path Parameter results in 404 response

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

>
> On Mon, Mar 14, 2011 at 8:44 AM, antalus <fr...@gmail.com> wrote:
>
>> Hi,
>>
>> I have a simple resource class
>>
>> @Path("{id}")
>> public class TestResource {
>>    @GET
>>    @Produces(MediaType.TEXT_PLAIN)
>>    public Response test(@PathParam("id") String id){
>>        final String result = String.format("Received PathParam: '%s'",
>> id);
>>        System.out.println(result);
>>        return Response.ok().entity(result).build();
>>    }
>> }
>>
>> When I do the GET request with path "/hello%3B" the response is:
>>
>> HTTP/1.1 404 Not Found
>> Content-Type: text/xml
>> Allow: GET,OPTIONS,HEAD
>> Date: Sun, 13 Mar 2011 08:17:40 GMT
>> Content-Length: 0
>> Server: Jetty(6.1.26)
>>
>> But what I expect from this request is that method test() is invoked with
>> "hello;" string as parameter.
>> So I think the problem is with encoded semi-colon %3B. Other encoded
>> special
>> symbols seem to work as expected.
>>
>> Is such behavior a bug?
>>
>>
> I'll write a test and get back to you asap.
>

It was a bug which is now fixed (CXF-3403, CXF-3404). First, the use of
HttpServletRequest.getPathInfo() for determining the base request URI was
problematic because the decoded value was returned and the matrix parameters
were lost on the last path segment - I added the workaround a long time ago
but it fails with %3B being decoded too. Another problem was in the JAX-RS
code itself, to do with decoding the PathParm values too early...

Thanks for reporting this issue...

Sergey

Re: JAX-RS: %3B in Path Parameter results in 404 response

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

Sorry for the delay - going to look at your issue next,

On Mon, Mar 14, 2011 at 8:44 AM, antalus <fr...@gmail.com> wrote:

> Hi,
>
> I have a simple resource class
>
> @Path("{id}")
> public class TestResource {
>    @GET
>    @Produces(MediaType.TEXT_PLAIN)
>    public Response test(@PathParam("id") String id){
>        final String result = String.format("Received PathParam: '%s'", id);
>        System.out.println(result);
>        return Response.ok().entity(result).build();
>    }
> }
>
> When I do the GET request with path "/hello%3B" the response is:
>
> HTTP/1.1 404 Not Found
> Content-Type: text/xml
> Allow: GET,OPTIONS,HEAD
> Date: Sun, 13 Mar 2011 08:17:40 GMT
> Content-Length: 0
> Server: Jetty(6.1.26)
>
> But what I expect from this request is that method test() is invoked with
> "hello;" string as parameter.
> So I think the problem is with encoded semi-colon %3B. Other encoded
> special
> symbols seem to work as expected.
>
> Is such behavior a bug?
>
>
I'll write a test and get back to you asap.

Thanks, Sergey


> Environment:
> CXF 2.3.3
> JDK 6 update 24
> Jetty 6.1.26 (via Maven plugin)
>
>