PDA

View Full Version : Post functionality


k-billy
04-05-2004, 01:13 PM
Trying to use the new Post functionality in the Laszlo 2.1 dataset. The xml we are sending back is quite large, and it is getting truncated by the server. Does the laszlo server code impose any limits on the length of the POST body?

Regards,

Caleb

vfunshteyn
04-05-2004, 02:39 PM
Could you post the code fragment where you are trying to submit a dataset using POST?

k-billy
04-05-2004, 02:47 PM
Here is the code. Our Canvas is set to version="1.1", in case that has any bearing on this problem.

<method name='saveDataPrivate' args='body, url, paramName, caller'>
Debug.write(this + ": saving: " + body);
var postSet = canvas.UtilLibrary_SaveDataset;
postSet.setSrc(url);
postSet.setQueryType("POST");
postSet.setQueryParam(paramName, body)
LzTimer.resetTimer(this.cancelRequestDelegate, 30000 );
postSet.doRequest();
LzTimer.removeTimer( this.cancelRequestDelegate);
Debug.Write("SaveTool.saveChunks() is completed");
</method>

pablo
04-05-2004, 02:57 PM
Hi Caleb,

Can you also tell us approximately how large your POST body is?

pablo

k-billy
04-05-2004, 03:03 PM
The lzx escaped is 436 kb. The reason it is so large is because we transform our xml object to a xml meta-dat equivalent. The meta-data contains local specific info, and a number of other things.

We are using Jetty for our app server.

vfunshteyn
04-05-2004, 03:04 PM
Originally posted by k-billy
Here is the code. Our Canvas is set to version="1.1", in case that has any bearing on this problem.

<method name='saveDataPrivate' args='body, url, paramName, caller'>
Debug.write(this + ": saving: " + body);
var postSet = canvas.UtilLibrary_SaveDataset;
postSet.setSrc(url);
postSet.setQueryType("POST");
postSet.setQueryParam(paramName, body)
LzTimer.resetTimer(this.cancelRequestDelegate, 30000 );
postSet.doRequest();
LzTimer.removeTimer( this.cancelRequestDelegate);
Debug.Write("SaveTool.saveChunks() is completed");
</method>

I don't believe that setting canvas version parameter to 1.1 makes any difference in LPS 2.x; somebody correct me here, if I'm wrong. In any case, try changing your code to something like this:

<method name='saveDataPrivate' args='body, url, paramName, caller'>
Debug.write(this + ": saving: " + body);
var postSet = canvas.UtilLibrary_SaveDataset;
postSet.setSrc(url);
postSet.setQueryType("POST");
postSet.setQueryParam('lzpostbody', body);
LzTimer.resetTimer(this.cancelRequestDelegate, 30000 );
postSet.doRequest();
LzTimer.removeTimer( this.cancelRequestDelegate);
Debug.Write("SaveTool.saveChunks() is completed");
</method>

This should work as long as you don't have any other calls to setQueryParam() -- of course, you'd have to prepend request parameters (if any) to the body prior to the call.

pablo
04-05-2004, 03:58 PM
This is from the dataset reference doc:

setQueryType(reqtype)

reqtype: A string -- either "GET" or "POST". GET is the default. When the type is "POST", the query parameters will be sent in the request body, encoded as application/x-www-form-urlencoded If the type is "POST" and there is a exactly one request parameter and it is named "lzpostbody", it will be used as the raw request body (unencoded). Use of "lzpostbody" with a request that has more than one request parameter is undefined.

k-billy
04-05-2004, 04:13 PM
I don't think this is working. I'm still getting a message saying
"WARN!! Form content truncated" in the server's standard out.

When I try to lookup the 'lzpostbody' parameter, there isn't any value in the HttpRequest object. I assume that Laszlo isn't giving it a name.

vfunshteyn
04-05-2004, 04:43 PM
If you take a look at the LPS log, you will see that whenever you make a POST request using the 'lzpostbody' parameter, the server logs a line like this:

05 Apr 2004 17:18:59 (127.0.0.1 9) INFO internal.DataSourceInternal - requesting URL: 'http://localhost:8080/lps/test/data/echo.jsp?lzpostbody=.....'

Even though it appears from this log entry as if LPS makes submits your data as a GET request, it's actually a POST. That's what I remember, anyway. But there may be a bug in the third-party Java library we're using for HTTP communications, that causes it to set a limit on the size of a POST request.

k-billy
04-06-2004, 08:12 AM
I just used curl to hit our servlet directly with the same data. It appears that Jetty is actually truncating the post data, not Laszlo. Sorry for the trouble. It is likely that I need to configure something differenlt in Jetty.

pablo
04-06-2004, 08:21 AM
I was actually in the process of testing this. There is a property you can set in jetty regarding the size of your POST body. I've included a post from one of the Jetty mailing lists below. Let me know if this helps.

Cheers,
pablo
--

Subject: [Jetty-support] Re: maximum size for a POST
From: "Helg Bredow" <Helg.Bredow@kalido.com>
Date: Tue, 11 Nov 2003 07:53:38 -0000
To: <jetty-support@lists.sourceforge.net>

"Eric Bloch" <bloch@laszlosystems.com> wrote in message
news:<3FAF282A.9050502@laszlosystems.com>...

>> Does jetty have a configuration setting for the maximum size of a POST
>> request?
>>
>> -Eric
>>
>>
>>
>>
>> -------------------------------------------------------
>> This SF.Net email sponsored by: ApacheCon 2003,
>> 16-19 November in Las Vegas. Learn firsthand the latest developments
>> in Apache, PHP, Perl, XML, Java, MySQL, WebDAV, and more!
>> http://www.apachecon.com/
>> _______________________________________________
>> Jetty-support mailing list Jetty-support@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jetty-support
>>


In the source code for org.mortbay.http.HttpRequest there is the
following declaration. This should help. Note that there is a mistake in
the comment, the system property is not what is actually used in the
code below. Setting this on the Jetty command line seems to do the
trick. Not sure if there's a way to set a system property in the
jetty.xml file though.

/* ------------------------------------------------------------ */
/** Max size of the form content.
* Limits the size of the data a client can push at the server.
* Set via the org.mortbay.http.HttpRequest.maxContentSize
* system property.
*/
public static int __maxFormContentSize=

Integer.getInteger("org.mortbay.http.HttpRequest.maxFormContentSize",
100000).intValue();


--------------------------------------------------

k-billy
04-06-2004, 09:21 AM
Hi Pablo and vfunshteyn,

that worked! Thanks for all of your assistance!

Caleb