Showing posts with label tool. Show all posts
Showing posts with label tool. Show all posts

Wednesday, December 12, 2007

HttpRequest-class

Fetching Post/Get parameters with an agent isn't easy in LotusScript with inbuilt tools.

I made this simple class today as a replacement for a get-only getParameter routine I used earlier. This class should handle both get- and post-requests.

My "documentation" (something new I've been trying out) of the class:


>> Class in a text-file
(the tabs are a little off in Notepad/Wordpad, but should look correct in DD)

>> Simple demoapp

Update, 01.07.2009: A small codechange to support multi-value requests. For instance from a form with checkboxes.

Update, 30.05.2008: There was a bug in the class. If you had a parameter containing "=", the parameter value would be cut off before =. The class is updated with the fix (demoapp not updated).

Update, 25.03.2008: I've updated the class so that it should handle request_content above 64k. Read more here.

Update, 13.12.2007: I updated the class with a method to print a html-report of the request, using the docToHTML-procedure in the previous post.

Update, 25.09.2008: Added functionality to fetch cookies from a request.

Debugging: Inspect what's being posted from a form

Sometimes I make parts of a form using PassThruHTML/hidden notes-fields. Mostly because Domino-generated HTML is hard to style (especially radio-buttons/checkboxes). This sometimes work immediately, and sometimes it takes hours to make it work. I've found it a great help to see what is being posted to the server.

There are HTTP-sniffer applications that you can inspect the request with, but I find it easier to post the form to an agent, and then print the request-content as a HTML-table.

Example of output, Jake's FakeNames database, Person-form with a couple of fields filled in.

It's also handy to "echo" get-requests when developing agents: A simple ?OpenAgent

In the demo-application for this blogpost, I've made a (javascript) action-button that rewrites the action-field in the form to point to an agent. The agent tries to print every field in NotesSession.DocumentContext.

To make this work in your applications, (hopefully,) you only have to copy the Script Library, InspectRequest, the agent inspectrequest, and the shared action, Inspect current form-values. Insert the shared action into the form you want to test.

To inspect DocumentContext in other agents, use docToHTML in the Script Library, InspectRequest. As a rare occurence, I've actually documented this function.

To get the current field-values, I trigger the equivalent of @Command( [ViewRefreshFields] ), using the Domino _doClick function.

>> Download demo application