[Gambas-user] HTTP Form

Gianluigi bagonergi at gmail.com
Sun May 15 23:38:18 CEST 2022


Il giorno dom 15 mag 2022 alle ore 20:10 T Lee Davidson <
t.lee.davidson at gmail.com> ha scritto:

> On 5/13/22 09:17, T Lee Davidson wrote:
> >
> When I get a bit of extra time, I'll try to work up an example that also helps show how a HTML form works server-side.
>
> Gianluigi ( and Hans :-) ),
>
> Here is the example. It consists of two applications: a server (using the
> embedded http server) and a client (utilizing HttpForm).
>
> Open and run the server application. You can close the browser window or
> tab that is automatically launched; we won't be using it.
> Then, open and run the client app. It does not matter what values you
> input; they will merely be echoed back in the HTML
> assigned to the TextArea.
>
> When we use a web browser to retrieve a web page containing a form and
> then submit that form, the process, very simply, looks
> like this:
> 1. The browser (the client) requests the web page (with the form) from the
> server using the GET method,
> 2. After receiving it, the browser interprets the HTML of the page and
> renders the form so the user can fill it in and submit it,
> 3. When the user submits the form, the browser sends the form data to the
> server using the POST method,
> 4. The server receives the form data, processes it according to its
> programming, and returns a response to the browser for
> display to the user.
>
> For more info, see
> https://developer.mozilla.org/en-US/docs/Learn/Forms/Sending_and_retrieving_form_data
>
>
> When we use HttpForm to submit a form, we omit the above Steps 1 and 2 and
> use HttpForm (as the client) in place of the browser.
>
> Unless we already know the HTML content of the form, we would need to use
> a browser, at least once, to look at the page source
> to determine:
> 1. What fields the form requires (which we simply .Add() to HttpForm),
> 2. What URL at which to post the data. This URL is given in the form
> element's "action" attribute. If it is a relative URL (see
> above reference), we need to expand it by prepending the domain name. When
> using the embedded HTTP server, for example,
> 'action="/"' would expand to 'action="http://localhost:8080/"'. So, we
> would need to specify:
> 'HttpForm.URL = "http://localhost:8080/"'.
>
> In this example, since the location of the page containing the form and
> the "action" URL are the same, the server determines
> whether to send the HTML form or to process the form data based on the
> HTTP method (ie. GET or POST) used by the client.
> HttpForm.Submit is a POST operation.
>
> I hope that I have explained it clearly enough and that the behavior of
> the code is self-explanatory. If not, please ask for
> clarification. I also welcome any comments or corrections.
>
>
> --
> Lee
>
> P.S. I was not able to use HttpForm to login in to the BugTracker. Curl
> appears to choke on submitting a form through a 302
> redirection due to: "necessary data rewind not possible".
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>

Hi Lee,

I just got home, thank you very much for your work.
Today is Gambas gift day :-)

Sorry but now I am tired and going to sleep, tomorrow I will calmly report
to you

Greetings

Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220515/b3e55d29/attachment.htm>


More information about the User mailing list