Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Brain fried -- Core dumped


devel / comp.lang.forth / An HttpRequest parser for GET requests in the Web-server-light

SubjectAuthor
o An HttpRequest parser for GET requests in the Web-server-lightJos Ven

1
An HttpRequest parser for GET requests in the Web-server-light

<cd7d79d1-fc02-45e7-9b1f-7bddf6b20202n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24044&group=comp.lang.forth#24044

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:4c48:0:b0:635:e500:8dc7 with SMTP id cs8-20020ad44c48000000b00635e5008dc7mr119679qvb.4.1689681726821;
Tue, 18 Jul 2023 05:02:06 -0700 (PDT)
X-Received: by 2002:a05:6830:1e30:b0:6b9:513:e364 with SMTP id
t16-20020a0568301e3000b006b90513e364mr2797337otr.1.1689681726615; Tue, 18 Jul
2023 05:02:06 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 18 Jul 2023 05:02:06 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=213.10.199.198; posting-account=nkqetwkAAACepkf86cwWAMB6YF6pRh3F
NNTP-Posting-Host: 213.10.199.198
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cd7d79d1-fc02-45e7-9b1f-7bddf6b20202n@googlegroups.com>
Subject: An HttpRequest parser for GET requests in the Web-server-light
From: josv@planet.nl (Jos Ven)
Injection-Date: Tue, 18 Jul 2023 12:02:06 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2262
 by: Jos Ven - Tue, 18 Jul 2023 12:02 UTC

Hi, I just released a new version (5.0) of the Web-server-light. The most important changes are:
1) Dictionaries are now used for GET requests, tags and svg parts.
2) Added an HttpRequest parser for GET requests. This saved me a lot of searches and error checking.

Here is how the parser for HttpRequests work: A web page gets the following button:
<button type="submit" NAME=0 VALUE="Switch" style="background-color:#BFBFBF; color:#000000" ; class="btn">Switch</button>

When the button is activated the web-server gets in the req-buf a string containing:
GET /home?1=Switch HTTP/1.1

Then handle-request ( recv-pkt$ cnt -- ) locates that line and does the following:
The characters ? = & are replaced by a space.
So the string to evaluate becomes:
GET /home 1 Switch HTTP/1.1

Then only words in the TCP/IP dictionary are used to evaluate the string.
The word /home is executed after the word HTTP/1.1 is executed.

Errors are catched and shown when possible.
The source for the HttpRequest parser is in Web-server-light.f at:
https://github.com/Jos-Ven/A-smart-home-in-Forth
It runs in Gforth and Win32Forth.

There is also a version for Cforth in webcontrols.fth at
https://github.com/Jos-Ven/cforth/tree/WIP/src/app/esp

Jos

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor