Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 43 |
Nodes: | 6 (0 / 6) |
Uptime: | 94:27:07 |
Calls: | 290 |
Calls today: | 1 |
Files: | 904 |
Messages: | 76,378 |
On Thu, 26 Dec 2024 12:40:33 +0000, okflo@teletyp.ist wrote:The 200 ms is indeed a crude way.
hi forthers,
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
but /read-socket/ doesn't return anything - result is pad 0 on
the stack.
probably I misunderstand howto use socket.fs?
additional question - has anyone already done bindings for
libcurl?
many thanks for any hints & merry christmas - okflo
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
Note: The site begins with https in a browser!
Jos
--
hi forthers,
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
but /read-socket/ doesn't return anything - result is pad 0 on
the stack.
probably I misunderstand howto use socket.fs?
additional question - has anyone already done bindings for
libcurl?
many thanks for any hints & merry christmas - okflo
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
close-socketcr type ;
Result after: test-http
HTTP/1.1 400 Bad Request
Server: awselb/2.0
Date: Fri, 27 Dec 2024 15:25:43 GM
Note: The site begins with https in a browser!
Jos