users@glassfish.java.net

[gf-users] Glassfish 4 returns 400 Bad Request for GET with payload

From: Cristi Chircu <cristian.chircu_at_gmail.com>
Date: Wed, 6 May 2015 21:56:10 +0300

Hello everybody,

 

The application I am working on has a Rest web service that expects a GET
request with a payload. I know it's not the way to go but for backward
compatibility we have to keep it at least for a while longer. This was
working fine in Glassfish 3 but now we want to upgrade to Glassfish 4 and
here it returns a 400 Bad Request. Looking around in the Glassfish 4 source
code I found this flag:

 

// flag, which enables/disables payload support for HTTP methods,

// for which HTTP spec doesn't clearly state whether they support payload.

// Known "undefined" methods are: GET, HEAD, DELETE

org.glassfish.grizzly.http.HttpServerFilter#allowPayloadForUndefinedHttpMeth
ods

 

By default this is false and this is why the 400 response is returned. This
flag seems to only be populated in the bellow method based on the server
config:

 

org.glassfish.grizzly.http.server.HttpServer#configureListener {

....

httpServerCodecFilter.setAllowPayloadForUndefinedHttpMethods(

                serverConfig.isAllowPayloadForUndefinedHttpMethods());

....

}

 

The serverConfig here is a final attribute that has a public getter but that
didn't get me anywhere.

 

After all this my question is: Is there any way of setting that flag to true
either programmatically (I doubt it) or from the admin GUI? Is there any
other way of getting this to work in Glassfish 4?

 

Thanks,

    Cristi