Sujet : Re: making http request with gforth
De : dave_thompson_2 (at) *nospam* comcast.net
Groupes : comp.lang.forthDate : 09. Jan 2025, 04:05:44
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <ssdunjhv7a59bt14rlcmeg2g2eo6mkcg0m@4ax.com>
References : 1 2
User-Agent : Forte Agent 3.3/32.846
On Fri, 27 Dec 2024 15:33:05 +0000,
josv@planet.nl (josv) wrote:
On Thu, 26 Dec 2024 12:40:33 +0000, okflo@teletyp.ist wrote:
I am trying to do a (very simple and naive) http-request
with gforth (current from git):
...
Try:
require unix/socket.fs
: test-http
s" httpbin.org" 80 open-socket >r
s" GET HTTP/1.1\nHost httpbin.org\n\n" r@ write-socket
200 ms
r@ pad 80 read-socket .s
r> close-socket
cr type ;
Result after: test-http
HTTP/1.1 400 Bad Request
Server: awselb/2.0
Date: Fri, 27 Dec 2024 15:25:43 GM
If you make it GET / HTTP/1.1\nHost: httpbin.org\n\n (with slash as
minimal path in the first line and colon in the second) it should work
(but need a larger buffer). Officially the line ends should be CR LF
(\r\n) but many servers including this one accept LF.
Note: The site begins with https in a browser!
Not in my browsers. And it doesn't even serve HSTS, which would cause
a browser to force HTTPS on visits after the first.