Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-1738

Handle application/x-www-form-urlencoded entity

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.0.0.Beta1, 3.5.0.CR1
    • None
    • None
    • None

      Given a resource method like

         @Path("test")
         public static class TestResource {
            
            @POST
            @Path("form")
            public String formParam(@FormParam("fp") String fp, String content) {
               return fp + "|" + content;
            }
      

      and

            ResteasyClient client = new ResteasyClientBuilder().build();
            Invocation.Builder request = client.target("http://localhost:8081/test/form").request();
            Response response = request.post(Entity.entity("fp=abc", "application/x-www-form-urlencoded"));
            System.out.println("response: " + response.readEntity(String.class));
      

      the output will be

      response: abc|
      

      because the entity will get eaten in the course of retrieving the form parameter.

              rsigal@redhat.com Ronald Sigal
              rsigal@redhat.com Ronald Sigal
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: