Skip to content
Thomas Cherryhomes edited this page Nov 12, 2020 · 11 revisions

The HTTP protocol allows for network communications over both HTTP and HTTPS.

Devicespec

The HTTP protocol devicespec is:

N:HTTP://HOST:PORT/PATH/?key=val

Open

Opening an HTTP connection is the same as any other protocol, and is defined here: N: SIO Open

AUX1 Values for Open

The aux1 value specifies the HTTP mode to use:

AUX1 Mode
4 GET
6 PROPFIND
8 PUT
13 POST

These specific aux1 values were chosen because they map to existing Atari conventions. Because of this, you can load and save files to and from HTTP servers transparently. PROPFIND is of course a WEBDAV call allowing for WEBDAV capable servers to return a disk directory. The odd man out, is 13, which is for HTTP POST.

AUX2 values for Open

Currently AUX2 is used to specify the translation mode for CR/LF to EOL. N: AUX2 Values

GET

When GET is specified, the URL is specified entirely in the devicespec, and subsequent reads will return the HTTP body of the request. Once the body has been returned to the Atari, any subsequent reads will return an error 136 (via the STATUS command).

GET CIO Example

Here is an example which retrieves a copy of the GPL 3.0 license from GNU.ORG over HTTPS, and displays it. Closing the result once EOF is reached.

10 DIM A$(128)
11 TRAP 60
20 OPEN #1,4,3,"N:HTTPS://www.gnu.org/licenses/gpl-3.0.txt"
30 INPUT #1,A$
40 ? A$
50 GOTO 40
60 CLOSE #1
70 END

POST

To POST to an HTTP server, you must first open with AUX1 mode 13. Upon opening, you then write your post data in the format the server expects. By default, this is MIME type application/x-www-form-urlencoded. Once you are finished writing, you must issue the HTTP POST to send the data to the server. You can then read back the resulting data.

POST Example

10 DIM A$(99)
20 OPEN #1,13,3,"N:HTTPS://postb.in/1605156266970-8865795242600"
30 PRINT #1;"foo1=bar1"
40 PRINT #1;"foo2=bar2"
50 XIO 80,#1,13,3,"N:":REM $80 is 'P' for POST
60 TRAP 100
70 INPUT #1,A$
80 ? A$
90 GOTO 70
100 CLOSE #1:END

Clone this wiki locally