Deutsch   English   Français   Italiano  
<c2ffb24b48489a30ecdbcf7f360a955c@www.novabbs.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.nk.ca!rocksolid2!i2pn2.org!.POSTED!not-for-mail
From: josv@planet.nl (josv)
Newsgroups: comp.lang.forth
Subject: Re: making http request with gforth
Date: Sun, 29 Dec 2024 13:12:26 +0000
Organization: novaBBS
Message-ID: <c2ffb24b48489a30ecdbcf7f360a955c@www.novabbs.com>
References: <87jzbmbose.fsf@news.diesenbacher.net> <2003f80ef2de7ad9f8c717551b55a466@www.novabbs.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
	logging-data="1017304"; mail-complaints-to="usenet@i2pn2.org";
	posting-account="uBg8qRGNmGMwwM8MgDv8UEJIuJQ29qkAO/Yca1ID9p4";
User-Agent: Rocksolid Light
X-Rslight-Site: $2y$10$OFWMANHNTIrlOKKUwx2pAedzDsZ2OpqeCwbgwuJwWgMGIdjS3ZJ0q
X-Spam-Checker-Version: SpamAssassin 4.0.0
X-Rslight-Posting-User: cc5e56b2fbc2db761f905374736421012c2539fc
Bytes: 2365
Lines: 58

On Fri, 27 Dec 2024 15:33:05 +0000, josv wrote:

> On Thu, 26 Dec 2024 12:40:33 +0000, okflo@teletyp.ist wrote:
>
>> 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
>
> --
The 200 ms is indeed a crude way.
See https://www.gnu.org/software/libc/manual/html_node/Listening.html
for more details especially the pages about listing and accepting
connections

I never used ssl/tls.
Jos

--