|
| 1 | +--- |
| 2 | +title: The Filehost ISUPPORT token |
| 3 | +layout: spec |
| 4 | +work-in-progress: true |
| 5 | +copyrights: |
| 6 | + - |
| 7 | + name: "Val Lorentz" |
| 8 | + email: "progval+ircv3@progval.net" |
| 9 | + period: "2022" |
| 10 | + - |
| 11 | + name: "Simon Ser" |
| 12 | + period: "2024" |
| 13 | +--- |
| 14 | + |
| 15 | +# filehost |
| 16 | + |
| 17 | +This is a work-in-progress specification. |
| 18 | + |
| 19 | +Software implementing this work-in-progress specification MUST NOT use the |
| 20 | +unprefixed `FILEHOST` ISUPPORT name. Instead, implementations SHOULD use the |
| 21 | +`draft/FILEHOST` ISUPPORT name to be interoperable with other software |
| 22 | +implementing a compatible work-in-progress version. The final version of the |
| 23 | +specification will use unprefixed ISUPPORT names. |
| 24 | + |
| 25 | +## Motivation |
| 26 | + |
| 27 | +This specification offers a way for servers to advertise a hosting service for |
| 28 | +users to upload files (such as text or images), so they can post them on IRC. |
| 29 | + |
| 30 | +## Architecture |
| 31 | + |
| 32 | +### ISUPPORT token |
| 33 | + |
| 34 | +This specification introduces the `draft/FILEHOST` ISUPPORT token. |
| 35 | + |
| 36 | +Its value MUST be a URI and SHOULD use the `https` scheme. Clients MUST ignore |
| 37 | +tokens with an URI scheme they don't support. Clients MUST refuse to use |
| 38 | +unencrypted URI transports (such as plain `http`) if the IRC connection is |
| 39 | +encrypted (e.g. via TLS). |
| 40 | + |
| 41 | +Servers MUST accept `OPTIONS` requests on the upload URI. Servers MAY return an |
| 42 | +`Accept-Post` header field to indicate the MIME types they accept. Servers MAY |
| 43 | +advertise support for [resumable uploads]. |
| 44 | + |
| 45 | +When clients wish to upload a file using the server's recommended service, they |
| 46 | +can send a request to the upload URI. The request method MUST be `POST`. |
| 47 | +Clients MUST include an `Authorization` header field with the `Bearer` scheme |
| 48 | +and a fresh token obtained via the `FILEHOST TOKEN` command. |
| 49 | + |
| 50 | +Clients SHOULD use the `Content-Type`, `Content-Disposition` and |
| 51 | +`Content-Length` header fields to indicate the MIME type, name and size of the |
| 52 | +file to be uploaded. |
| 53 | + |
| 54 | +On success, servers MUST reply with a `201 Created` status code and with a |
| 55 | +`Location` header field indicating the URI of the uploaded file. Servers MUST |
| 56 | +support `HEAD` and `GET` requests on the uploaded file URI. |
| 57 | + |
| 58 | +Clients SHOULD gracefully handle other common HTTP status codes that could |
| 59 | +occur. |
| 60 | + |
| 61 | +### `FILEHOST TOKEN` command |
| 62 | + |
| 63 | +When the `draft/FILEHOST` ISUPPORT token is advertised, servers MUST support |
| 64 | +the `FILEHOST TOKEN` command. When sent from the client, the command takes no |
| 65 | +parameter: |
| 66 | + |
| 67 | + FILEHOST TOKEN |
| 68 | + |
| 69 | +The server MUST reply with a successful `FILEHOST TOKEN` or a `FAIL` reply. |
| 70 | +A successful `FILEHOST TOKEN` server reply has the following syntax: |
| 71 | + |
| 72 | + FILEHOST TOKEN <token> |
| 73 | + |
| 74 | +Servers MUST ensure that tokens are short-lived and MAY invalidate tokens once |
| 75 | +they are used. |
| 76 | + |
| 77 | +## Examples |
| 78 | + |
| 79 | +Example isupport token: |
| 80 | + |
| 81 | + :irc.example.org 005 seunghye draft/FILEHOST=https://irc.example.org/upload |
| 82 | + |
| 83 | +Example `OPTIONS` response: |
| 84 | + |
| 85 | + HTTP/1.1 204 No Content |
| 86 | + Allow: OPTIONS, POST |
| 87 | + Accept-Post: image/*, video/* |
| 88 | + |
| 89 | +Example token query: |
| 90 | + |
| 91 | + C: FILEHOST TOKEN |
| 92 | + S: FILEHOST TOKEN oophay9HohKeAhb1nohy1iec |
| 93 | + |
| 94 | +Example `POST` request: |
| 95 | + |
| 96 | + POST /upload HTTP/1.1 |
| 97 | + Host: irc.example.org |
| 98 | + Content-Type: image/jpeg |
| 99 | + Content-Disposition: inline; filename="picture.jpeg" |
| 100 | + Content-Length: 4242 |
| 101 | + Authorization: Bearer oophay9HohKeAhb1nohy1iec |
| 102 | + |
| 103 | +Example `POST` response: |
| 104 | + |
| 105 | + HTTP/1.1 201 Created |
| 106 | + Location: /upload/hoh5eFThae4e.jpeg |
| 107 | + |
| 108 | +[resumable uploads]: https://datatracker.ietf.org/doc/draft-ietf-httpbis-resumable-upload/ |
0 commit comments