-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow protocol discovery between client and server. #29
Comments
I'm interested in this subject. My use case will be different though. The clients I'm about to support are mobile nodes that will support a single version of the protocol, but different clients may support different versions. Server must support many versions, depending on what clients are deployed. I want server to detect which version it is and adjust, so ideally, I would want client to include a header in their File Creation request, as that's probably the first thing they're going to send. Request:
Response:
Or, when server no longer supports some version (not the best situation for me, but can happen and should be specified), it could return an error, and at the same time indicate the preferred version to be used.
|
On the other hand, are request headers the right way to do it? Perhaps there should be separate URLs to initiate uploads in separate versions? E.g. POST /0.2.2/files. |
@qsorix But wouldn't that be solved with what @timemachine3030 proposed? That you first do a HEAD request to the server to figure out if your client's protocol version is supported? Another idea: We could introduce an endpoint that you can send a HEAD request to which returns you a list of protocol versions that are supported. I don't really like this, but I wanted to throw it into the discussion anyways. I think what @timemachine3030 proposed makes sense ... you could just send a HEAD request with the protocol version you'd LIKE to use. And if that is not available you would send more HEAD requests to figure out the latest version you can support with your client. |
I'm fine with @timemachine3030's proposal. In my comment i was trying to say that my use-case is reversed. This:
In my case is not important. I have thousands of remote embedded devices, and each support only a single version of protocol. Since upgrades are spread in time, on the server I need to support (almost) all versions of the protocol. So my use case is to "allow the server to recognize the protocol version used by the client". My clients MUST advertise the version of the protocol they're using in every request they make. There's no negotiation, and if there was, it would not be optional. So I prefer clients to just include a header and follow their version of the protocol, instead of asking them to do additional request, just to dicover what's supported on the server. My clients have no choice but to assume the version they're running is supported on the server. And on the server, we must support all versions that are in use by some clients. As clients are being upgraded, we gradually drop support for older versions. What @timemachine3030 wrote is OK for a typical web-oriented use case, where a single rich client may connect to several servers. Each server may run a different version of the protocol, so the client want to figure out the protocol version to use. I'm happy with the original proposal. I just need to extend it so that:
|
I see, these extensions make sense to me. What do you think @timemachine3030 ? |
There are additional perks to protocol discovery: In addition to the protocol version number, the server may also serve supplemental data that is specific to that implementation or configuration, like maximum request size allowed or session time length. These are important enough for the client to be aware of. |
Great comments from everyone. @qsorix, Yes I see the need to send a version identifier with every request. It is important that the protocol's advise understands that there are situations where the server is sophisticated and the client is dumb and vise versa. As an additional note, I think that the client should still make an initial handshake request in the form of a An example scenario is where the Some items for additional discussion are,
|
We should include the version in every request and response. The client must send its version in the request and the server its version in the response. This is in conflict with @qsorix's idea to use the URL (#29 (comment)) since tus does not specify URL endpoints (and it should not start to do so).
For this case, the server supports multiple versions, we could allow multiple versions to be returned by the server, e.g.
where the first ones are preferred (use 1.0.0 if supported else 0.2.2 or 0.2.1).
I agree although we should try to avoid to put every piece information into one request/response. Instead I would like to introduce another method to retrieve this data. In addition to maximum size and session time length I would suggest to list the supported extensions. |
I could thing of following:
An |
@Acconut, looks good. I like it. TUS-Resumable can appear multiple times or contain a comma-separated list, right? And TUS-Resumable (with a single version that's actually used) MUST be included in all other (not OPTIONS) requests, right? And in responses as well? Which versions should server report back? All supported? The preferred one from what client advertised? Up to the implementation to decide? Minor comment. Perhaps it should be |
It should be a comma-separated list of all supported versions where this first elements are the preferred ones. So
Yes, that's how you can determine whether the client/server supports tus (and which version).
Good point, I agree. |
Cool. +1. Two questions about this:
First. It would also be valid to do two headers, right? E.g.
Second. Do we go with a plain list or bother with "Quality factors"? HTTP uses quality factors (q=0..1) to declare preference. E.g.
As a programmer, I like the sorted list much better because it is easier to parse. On the other hand, if existing libraries that deal with HTTP headers support quality factors, then programming convenience is not an issue, and I believe staying consistent with the established convention makes sense. When there is no quality factor, the default is 1. In this example:
both versions have the same priority. It can be implementation defined how to pick one, and we can suggest to pick them in order (server/client SHOULD). But if we agree to honour q=, then this
Must also favour 1.0.0 over 0.2.1. The library I use, does not parse this stuff. Hypothetically, there can be a library that goes too far and not only parses it, but also reorders the values to make it easier to the programmers to pick the most preferred one. When deciding on this, I would consider two things:
I'm happy to agree that a plain list is all we need. |
As far as I know it's supported mostly everywhere (this is in the HTTP spec, see
Again, good point. I don't have a strong opinion on this. The advantage of quality factors are that you can have multiple versions with the same factor but considering the price of parsing. I would prefer using the plain list just because of simplicity. |
Here's what I would suggest: Add to TUS-ResumableThe TUS-ExtensionThis header MUST be a comma-separated list of the extensions supported by the server. If no extensions are supported TUS-Max-SizeThe TUS-VersionThis header MUST be a comma-separated list of the supported versions of the tus resumable upload protocol by the server. The lists elements are sorted by the server's preference whereas the first element is the most preferred one. Add to OPTIONSAn @qsorix As you see I added the TUS-Version header which contains the list of the supported versions. Its value may be different from TUS-Resumable which indicates the currently used version. |
See #48 for the proposed changes. |
Sorry for a late response, I stayed offline duringe christmas. @Acconut, please remind me why for TUS-Version only server is mentioned? Clients are expected to first send OPTIONS, then pick the version and send requests using the proper one? If so, I'm +1. Will it say anywhere what happens when server doesn't like client's version? I.e. what's the proper way to reject invalid requests? I think it would help if every header was accompanied by a sensible example, to limit possible confusion regarding formating etc. |
No problem, we still have time until 1.0 needs to be done. :)
I agree. An example for an
Yes, that's how it is intended by me. The server doesn't need to know which versions the client supports, it must only be aware of the version the client is using in its requests.
Good point I forgot about! I vote for |
I'm fine with |
See a7ba01a. |
+1 |
Merged in 7c4fd4b. |
If writing an application that is able to upload to many different servers, the application will need to check if the remote server supports this protocol. Therefore, I suggest the following protocol extension to start a conversion on the topic.
(Note: that servers that do not support the tus protocol will reply to
HEAD
requests with either200 OK
or404 Not Found
)Protocol Discovery
All implementations SHOULD include the protocol discovery API to allow clients to negotiate, with a server, a common supported version of this protocol.
When making a
HEAD
request for a new file the client MAY include aTUS-Resumable
header with the version of this protocol.When receiving a
HEAD
request with theTUS-Resumable
header the server MAY reply with the202 Accepted
status and the currentOffset
.Example
Request:
Response:
The text was updated successfully, but these errors were encountered: