Tuesday, March 25, 2008

Improved HttpRequest class - Handles request_content above 64k

For those of you that haven't heard, in Domino 7.01, IBM implemented a workaround for (HTTP POST) request-content above 64k.

I've updated the HttpRequest class, so that it handles requests above 64k automagically.

>> My testbed for the class
The test-app has a page that posts ~260k of data to an agent. This results in 4 request_content fields. The agent prints a report of the request ( [HtppRequest].printHtmlReport ).

The class (txt-file)

Let me know if there are errors.


Cristian D'Aloisio said...

Hi Tommy,
thanks for sharing!


Patrick said...

The HttpHelpers class is really sweet. Worth investigating, thank you!

Veer said...

I might not have viewed the code properly but in the Function HTMLReport you are using a stream to build the report. However you use a variable to return the contents of the stream back.

Don't you have a 64K limit on variables?

Tommy Valand said...

According to the documentation, the limit on length of a string value is 2GB.

Maximum storage capacity is limited by available memory, but an array can not contain more than 64k elements. This is because the array is indexed by an integer, which goes from -32,768 to 32,767.

If I understand the documentation correctly, the limit on a fixed-size array, they can only contain 64k of data.

The array I use to fetch the parameters is a dynamic array.

NotesStream.ReadText can return a maximum of 2GB of data (probably due to the String data type limitation).

The question was a little vague. Hope I answered your question..

Veer said...

I didn't realize the string value can be 2GB. Can you point me to the right place in the documentation?

Tommy Valand said...

Search for "limit and string" in the Designer help.

Should be the first result..

Thelay said...

Hi, I am using domino 6.5. In some of the page. request content can't show properly. As long as I know domino field is only 32kB max. Even though CONTENT_LENGTH shows 82738 . But data become blank.

pls help. I need it urgently

Tommy Valand said...

As far as I know, you can't handle request content above 64k bytes in an agent if the server version is less than 7.

The only workaround I can think is to post to a richtext-field in a document.

Thelay said...

Hi, I am sorry to bother u again.

Can give me some example? I am quite new with lotus notes

Rather than lotus script, is there any other script I can use?

Thanks a lot.

Tommy Valand said...

Domino RichText items can hold a lot more data than standard fields, which as you say are limited to 32k. Use a richtext field if you want to handle more than 32k.

In field properties in the form, you can select Rich Text as the type of the field. Search for Rich Text in the documentation for more info.

Thelay said...

I am using agent to run. I use this code as follows,

If (doc.HasItem ("Request_Content")) Then

How do I have to use Rich text. Pls give me some example.


Tommy Valand said...

It's quite hard to give an example for a somewhat complex task, but I'll try to give you a rough recipe.

Create a form.
Add richtext items with the same name as the fields you're posting that will contain more than 32k of data. Add regular text/number fields for values that are shorter than 32k.

Instead of posting to an agent, as you're doing now, post to the form.

For instance, if you're using a HTML-form to post with:

Form action (post_form is the new form): http://yourdomain.com/database.nsf/post_form?CreateDocument

Make sure that the Notes Form has the same fields as the HTML form, so that you capture all field values. You may need to set enctype=multipart/form-data in the html form to make Domino accept data into the Rich Text items. I'm not sure.

Create a WebQuerySave agent to handle the values that are posted to the form/set that the agent should run on webquerysave.

If you don't want to store the document created, add a field, SaveOptions, with computed for display value of "0".


Try, fail, learn..repeat....succeed.