Sujet : Re: making http request with gforth
De : okflo (at) *nospam* teletyp.ist (okflo)
Groupes : comp.lang.forthDate : 27. Dec 2024, 21:59:17
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <87pllcc062.fsf@news.diesenbacher.net>
References : 1 2
User-Agent : Gnus/5.13 (Gnus v5.13)
Hoi Jos,
josv@planet.nl (josv) writes:
I am trying to do a (very simple and naive) http-request
with gforth (current from git):
>
#+begin_src forth
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
r@ pad 80 read-socket
r> close-socket ;
#+end_src
[...]
additional question - has anyone already done bindings for
libcurl?
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
thanks - that did it - so at least from a conceptual point of view :) I
did it right...
but what would be right way to /wait/ for a response? 200ms is just a
guess, isn't it? :)
Note: The site begins with https in a browser!
yep, ssl/tls would be my next question, actually I hoped, someone could
point me to a library f.e. incorporating libcurl or something similar.
Jos
okflo
--