HTTP 0.9 queries

I have a temperature-monitoring device that responds only to HTTP 0.9 queries (and the company no longer is in business). Can Racket do it? It looks like Racket's command requires HTTP 1.0.

Failing that, what I have been able to do successfully is issue a curl command from AppleScript. Would Racket be able to do something similar?

2 Likes

I don't know about using http 0.9 directly, or how difficult it would be to downgrade an implementation from 1.0 to 0.9 or write an 0.9 one from scratch.
Also there might be proxies out there that can connect to 0.9 and give you an 1.0 or higher interface haven't looked for that, just a thought.

You can use the system function to call the curl command directly 15.4 Processes > system
While that is easy for simple uses you may find that using process and its variants further down on that page, may be easier if you need more control about specific details.

Another possibility might be to use curl via racket's ffi and libcurl, but I have no practical experience with that and it might be more work.

A whole other (kind of hacky) possibility might be to make a request with curl capture the request and response with a reverse proxy (or I think curl can also do that with the right flags) and then figure out from there the minimal set of stuff that needs to be send and the easiest way to parse what you receive as response.

That said curl via subprocess / commandline seems like it may be the easiest way.
If you have extensive commandline like interactions in scripts rash might be useful.

3 Likes

Based on a quick look at the RFC that defines HTTP/1.0, it looks like HTTP/0.9 was formalized by the same document, and in fact HTTP/0.9 responses are also valid HTTP/1.0 responses. So, if I understand the document correctly (and I probably don't), it sounds like the only change required is to send the initial request without the HTTP version number.

It seems to me like the "next steps" depend a lot on how comfortable you are with various solutions. My personal inclination would be to try using a TCP library to open a connection, send a request, and take a look at the response. With luck, you can then use library functions to parse the result; I think the net library is written to make this fairly convenient.

But sure, you could definitely also just shell out to curl.

3 Likes

Thanks so much! The system function was all it took.

2 Likes