suspended requests, Params data cannot parse request.body

Bug #618741 reported by leizi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
play framework
New
Undecided
Unassigned

Bug Description

when suspended requests call again ,the Request.body inputstream have parsed before,so when Params checkAndParse the request.body,return nothing, maybe need reset the request.body.
code :
public void checkAndParse() {
            if (!requestIsParsed) {
                Http.Request request = Http.Request.current();
                String contentType = request.contentType;
                if (contentType != null) {
                    DataParser dataParser = DataParser.parsers.get(contentType);
                    if (dataParser != null) {

                        _mergeWith(dataParser.parse(request.body));
                    }
                }
                requestIsParsed = true;
            }
        }

maybe:

public void checkAndParse() {
            if (!requestIsParsed) {
                Http.Request request = Http.Request.current();
                String contentType = request.contentType;
                if (contentType != null) {
                    DataParser dataParser = DataParser.parsers.get(contentType);
                    if (dataParser != null) {

          if(!request.isNew)
       {
       try{
       request.body.reset();
       }
       catch(Exception ex)
       {
        requestIsParsed = true;
        return;
       }
       }

                        _mergeWith(dataParser.parse(request.body));
                    }
                }
                requestIsParsed = true;
            }
        }

Revision history for this message
Erwan Loisant (eloisant) wrote :

In what version is it present? 1.0 or 1.1, or both?

Revision history for this message
leizi (jiao-3rock) wrote :

both versions have this problem;

test sample:

import play.mvc.*;
import play.libs.WS;
public class Application extends Controller {

    public static void index() {
        render();
    }
 public static void toSuspended(String name)
 {
  if(request.isNew)
  {
   suspend(1);
  }
  //when post,name will be null
  renderText("name:"+name);

 }

 public static void testPost()
 {
  renderText((WS.url("http://localhost:9000/Application/toSuspended").setParameter("name","leizi").post().getString()));

 }

}

umcommend play.pool=3 in the application.conf

visit the http://localhost:9000/Application/testPost
the page will show:
name:null

Params.get("name") is null too

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.