Skip to content
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

Resumable Upload: Discovering upload limits upfront #2833

Open
Acconut opened this issue Jul 18, 2024 · 6 comments
Open

Resumable Upload: Discovering upload limits upfront #2833

Acconut opened this issue Jul 18, 2024 · 6 comments

Comments

@Acconut
Copy link
Member

Acconut commented Jul 18, 2024

Problem

#2747 introduced Upload-Limit for the server to indicate limits on the upload resource (e.g. maximum size). These limits are announced to the client during upload creation in the informational or final responses. However, the client cannot discover these limits without attempting to create an upload resource. A client may want to avoid creating an upload resource if it knows the the server limits cannot be satisfied.

Possible solution

A possible solution is to allow clients to send an OPTIONS request upfront to the URL from upload creation. The server might then include the Upload-Limit header in its response, so that the client knows them before trying to create an upload resource. However, a client is not required to send this OPTIONS request upfront.

This would also be handy in a possible future where browsers natively implement resumable uploads. The response for a CORS preflight request might then already include information whether the endpoints supports resumable uploads and, if so, under which constraints. The browser can use this data to optimize the uploads.

@Acconut Acconut changed the title Resumable Upload: Discovering upload limits Resumable Upload: Discovering upload limits upfront Jul 18, 2024
@smatsson
Copy link

Early thought: Would it be beneficial to include some kind of marker that this endpoints supports resumable upload in the OPTIONS response? For client's that does not support upgrading requests (e.g. due to lack of support for 1xx responses) who whishes to know upfront if the upload can be split (Upload-Complete: ?0) or if a regular upload (without resumability) should be performed.

@Acconut
Copy link
Member Author

Acconut commented Jul 23, 2024

Interesting idea! The presence of the Upload-Limit header could be used as an indicator for support of resumable uploads. In theory, its value can be an empty dictionary as well if the server does not impose any limits.
If the response does not include the Upload-Limit header, the client can either attempt an upgradable upload or directly fall back to regular uploads.

@LPardue
Copy link
Contributor

LPardue commented Jul 23, 2024

https://httpwg.org/specs/rfc8941.html#rfc.section.3.2

As with Lists, an empty Dictionary is represented by omitting the entire field. This implies that fields defined as Dictionaries have a default empty value.

@smatsson
Copy link

Too bad we can't use the empty dictionary header as an indicator. It's probably an edge case anyway that a client, not knowing the support of the server, would issue an OPTIONS request to find out? Or maybe not, given CORS? What do others think?

@Acconut
Copy link
Member Author

Acconut commented Jul 29, 2024

Thanks for the pointer, Lucas! If we cannot use an empty value, a server could also fill in a dummy value, e.g. Upload-Limit: min-size=0. This is only necessary if the server does not apply any limit at all (not even max-size), which I suppose is very rare in reality.

In general, the situation where a client wants to know upfront whether the server supports resumable uploads appears like an edge case to me. I assume the client will often know that the server supports it or otherwise will attempt to transparently upgrade a traditional upload into a resumable one. So I don't think we have to spend too much energy on this. How do you feel about this, Stefan?

@smatsson
Copy link

@Acconut Yeah I think that is fair enough. The use cases where a generic client (without prior knowledge of server support nor support for informational responses) would send an extra OPTIONS request seems slim to none. The CORS example is interesting but mostly (always?) happens in a browser which does support informational responses and thus would use the 104.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants