This Question is Answered

14 "helpful" answers available (3 pts)
3 Replies Last post: Jun 4, 2008 11:25 PM by URPradhan

Strange problem with HttpForm

Jun 4, 2008 5:23 AM

Click to view URPradhan's profile Level 7 URPradhan 141 posts since
Mar 6, 2008
HI Friends

I'm stucked with a strange problem with HttpForm. I have the below code for making a GET request o server. But nothing is getting going to server after "?" from the URL.
{let sid:String = "xxxxxxxxxxxxxxxxxxxx"} || Getting and storing here session id 
 
{let cb:CommandButton = 
              {CommandButton
                        label = "Logout",
                        let svrReplyStream:#HttpTextInputStream
                        {on Action do
                                 {try
                                            set svrReplyStream = {cmdLogout.form.submit-open}
                                             ||XXXXXXXXXXX Do other stuffs
                                            {svrReplyStream.close}
                                  catch e:Exception do
                                           {popup-message  e.message}
                                  }
                         }
               }
}
 
{let frmLogout:HttpForm = 
         {HttpForm
                  {url "http://www.xyz.com/logout.php?sessionid=" & sid}, || Here after the ? symbol nothing is going to server as I checked with Ethereal packet scanning
                  target="_self",
                  method=HttpRequestMethod.get,
                  cb || Above Command Button
         }
}
 
{value frmLogout}


I surprise that even though the URL's stem, leaf, query are ONE string, how come only stem+leaf+? are going to server and dropping the query ??????????

//Thank you in adv
Click to view tdeng's profile Level 3 tdeng 35 posts since
Oct 17, 2007
1. Re: Strange problem with HttpForm Jun 4, 2008 6:23 AM
I'm afraid you need to put all the data you want to send to server into your HttpForm, instead of putting some of them within the url query string when using HttpForm.
Here is a fixed sample:
{curl 6.0 applet}

{let sid:String = "xxxxxxxxxxxxxxxxxxxx"} || Getting and storing here session id

{let cb:CommandButton =
{CommandButton
label = "Logout",
{on Action do
{try
{let svrReplyStream:#HttpTextInputStream}
set svrReplyStream =
{cb.form.submit-open}

||XXXXXXXXXXX Do other stuffs
{svrReplyStream.close}
catch e:Exception do
{popup-message e.message}
}
}
}
}

{let frmLogout:HttpForm =
{HttpForm
{url "http://www.xyz.com/logout.php"}, || Here after the ? symbol nothing is going to server as I checked with Ethereal packet scanning
target="_self",
method=HttpRequestMethod.get,
{VBox
cb || Above Command Button
,{TextField width=0cm, height=0cm,name="sessionid",value=sid}
}
}
}

{value frmLogout}

But I'm also curious about why HttpForm don't support this.

Click to view wbardwell's profile Curl wbardwell 46 posts since
Oct 31, 2007
2. Re: Strange problem with HttpForm Jun 4, 2008 7:28 AM

If you do a GET HTTP request with HttpFormData or HttpForm, then the data from the form replaces the query string. This is because the code which is generating the query string can't know how it should append the parameters to an existing query string.

If you need to include a hidden variable in your HttpForm, you can just pass an instance of any of the HttpFormParam subclasses to the HttpForm constructor and it will get included with the form submission. (See the HttpForm doc string for details.)

Click to view URPradhan's profile Level 7 URPradhan 141 posts since
Mar 6, 2008
3. Re: Strange problem with HttpForm Jun 4, 2008 11:25 PM
in response to: wbardwell
@Tdeng
Thank you.

@wbardwell
Thank you for explaining the thing. Now its clear to me.