bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proof of Concept HTTP Client Function


From: port19
Subject: Proof of Concept HTTP Client Function
Date: Wed, 30 Aug 2023 09:08:17 +0000

Hi all,

I'm currently rewriting a small reddit client in awk.
(It was originally written in clojure in Q1 this year)

In the process I obviously need to make an http request.
The following function works well for now:

function request(domain, endpoint)
{
    target = "/inet/tcp/0/" domain "/80"
    payload = "GET " endpoint " HTTP/1.1" "\r\n" "Host: " domain ":80" "\r\n" 
"User-Agent: gawk" "Connection:close" "\r\n\r\n"
    print payload |& target

    while ((target |& getline line) > 0)
        response = response "\n" line
    close(target)

    return response
}

Note that this pads the response with one empty line both at the start and end.
The problem I'm facing now is an HTTP 301, since reddit happens to only support 
https.
Before running off to implement a tls handshake I thought I'd first share my 
progress.
Has anyone written any relevant ciphers for the tls?

Project in question: https://github.com/port19x/redqu/tree/gawk

Best
port19



reply via email to

[Prev in Thread] Current Thread [Next in Thread]