How to handle uploaded data?

So I've been writing a Spartan server, and I've realised I actually have no idea what to do with data that gets uploaded to it. I myself don't need a Spartan server that data can be uploaded to, but if someone else wants to use it and they need to allow data to be uploaded so people can log in, make comments, or something else, how would the server handle that? I guess maybe send it to some other software, but how would that work? How would someone tell it to send the data to a specific program?

Currently it just responds to requests containg data with a 5 error that says uploading data is unsupported.

Posted in: s/Spartan

๐Ÿš€ asdf

2025-02-18 ยท 1 year ago

4 Comments โ†“

๐Ÿš€ clseibold [๐Ÿ›‚] ยท 2025-02-18 at 10:42:

If you're writing server software that isn't a "framework" library where you can extend the server by using it as a library, then uploaded data can be handled by adding support for CGI and SCGI applications. This will allow users of your server to be able to do stuff with uploaded data.

Uploaded data that goes to known CGI/SCGI files/routes will hand the data off to those. Otherwise, uploaded data should be rejected.

๐Ÿš€ asdf [OP] ยท 2025-02-18 at 16:27:

Another question, what about redirects? How does the server know where the requested resource is, if it is not at the requested location? How does it even know it exists?

๐Ÿš€ clseibold [๐Ÿ›‚] ยท 2025-02-19 at 08:37:

@asdf For that you would have to have some configuration to allow users of your server to specify routes that they want redirected to a different route.

This same route configuration file would also be used to setup a route for an SCGI server (and if you want, CGI scripts as well).

For an example of a server that does this, you can see skyjake's GmCapsule's rewrite.* and cgi.* settings:

โ€” GmCapsule

๐Ÿ™ norayr ยท 2025-03-20 at 12:25:

i just saw your post, and i just asked a question in this subspace.

i want my students who already implemented spartan client that gets data, also to upload data. but i have no idea how to test this.

do you see how can i test this by using your server? lets say can it write all strings uploaded to one file, that is publicly accessible via spartan?

or how do i write such a cgi? for any spartan server? which spartan server would you recommend?