[Developers] When Doing HTTP GET, use Mode 12 !

TL:DR – When opening an HTTP GET connection, use mode = 12. Mode = 4 now does URL encoding of the path when it’s passed in, and will probably not be what you want.

While Mode = 4 is also an HTTP GET, it will attempt to resolve filenames and encode them so that they can be safely passed to and from a web server. It is intended for accessing plain files on HTTP and WebDAV servers.

So if you’re doing this in ATARI BASIC:

Change it to this:

For cross-platform C programs written in fujinet-lib, use the HTTP_GET_H constant in nopen():

network_open(buf, OPEN_MODE_HTTP_GET_H, OPEN_TRANS_NONE);

While Apple2 users using the AppleSoft BASIC extension should do:

& NOPEN 0, 12,0, "N:HTTPS://APPS.IRATA.ONLINE/Homesoft/?query=1234"

The Change, in Detail

Web servers, and in fact the standard that dictates the format of a URL give special meaning to characters like ? and &, as well as disallowing spaces. If these characters are to be used as part of a file name, they must be encoded so that the web server can pass them through literally.

On the ATARI, at least. You have the N: device. It can open any type of network connection, including to a networked filesystem. This can be used to access files stored on web servers. The encoding of filenames can break the seamless transparency expected, so some additional processing now happens in the FujiNet firmware to encode filenames so that web servers will treat them literally.

For example, with the latest change, this command works as expected:

On Open, the HTTP protocol adapter executes this piece of code here: https://github.com/FujiNetWIFI/fujinet-firmware/blob/master/lib/network-protocol/HTTP.cpp#L322

    if (aux1_open == 4 || aux1_open == 8)
{
// We are opening a file, URL encode the path.
std::string encoded = mstr::urlEncode(url->path);
url->path = encoded;
url->rebuildUrl();
}

return !client->begin(url->url);
}

Which transforms the above entered URL into:

Atari_8-bit%2FGames%2FHomesoft%2FFrogger%20%28Parker%20Brothers%29.xex

…before opening, so the web server is happy.

It does, however, make a bit of a mess when dealing with query parameters, as characters like ? get encoded, and the web server treats them literally as part of the path, rather than as the special query character:

Atari_8-bit/Games/Homesoft/F/Frogger/Frogger (Parker Brothers).xex?query=foo

gets the query part mangled into:

%2FAtari_8-bit%2FGames%2FHomesoft%2FFrogger%20%28Parker%20Brothers%29.xex%3Fquery%3Dfoo

…a mess.

This is why if you’re utilizing some web address that does an HTTP GET, and accepts query parameters, to please use mode 12, which does not do any transformation of the input, and passes it to the web server, unmolested.