reiern70 opened a new issue, #2024:
URL: https://github.com/apache/wicket/issues/2024

   ## Summary
   
   This is a follow-up to the resumable upload of #2010 (master), #2011 (11.x) 
and #2016 (10.x).
   
   A good part of its server side has nothing to do with Wicket: the tus 1.0 
protocol, the registry of uploads with its limits and expiry, the grants and 
how they are signed, and the tracker of the uploads. This issue proposes moving 
those parts into classes that depend only on the JDK, and on the servlet API at 
most. Wicket keeps a thin adapter, and another project can reuse the core: a 
plain servlet, a Spring or Jakarta REST application, or another web framework.
   
   I suggest doing this after the PRs are reviewed, so they stay reviewable. 
The public API of the PRs stays as it is.
   
   ## What depends on Wicket today
   
   - `ResumableUpload` and `ReceivedFileItem` need nothing from Wicket.
   - `IUploadsTracker`, `TrackedUpload` and `IUploadGrantSigner` only use 
`IClusterable`.
   - `UploadGrant` reads its query from `IRequestParameters` and uses `Bytes`.
   - `HmacGrantSigner` keeps its `inSession()` key in the Wicket `Session`. 
`CryptFactoryGrantSigner` uses the application's crypt.
   - `ResumableUploadResource` reads and writes the request through 
`WebRequest` and `WebResponse`, and hands a complete file to the `Form` of its 
`FileUploadToResourceField`.
   - `ResumableUploadResourceReference` covers several Wicket concerns:
     - mounting the resource;
     - the session id as the default owner;
     - deleting the uploads when the session ends or the application stops;
     - handing a complete file over as a `FileUpload` to the 
`IUploadsFileManager`.
   
     The registry, the limits, the expiry sweep, the locks and the folder of 
partial files in the same class do not need Wicket.
   - `ResumableUploadToResourceField` and its script are Wicket components and 
stay in Wicket.
   
   ## Proposed split
   
   ### A tus core with no Wicket imports
   
   - A protocol handler for OPTIONS, POST, HEAD, PATCH and DELETE. It reads the 
tus headers, `Upload-Offset` and `Upload-Metadata`, and writes the error 
answers.
   - An upload registry:
     - the uploads kept in memory;
     - the limits per owner and in total, and the free disk space;
     - the expiry sweep and the locks;
     - the partial files in their folder.
   - `UploadGrant`, `IUploadGrantSigner`, and `HmacGrantSigner` with `random()` 
and with a key the application supplies.
   - `IUploadsTracker` and `TrackedUpload`.
   - The owner as a string the caller passes in. The core does not look it up 
in a session.
   - A callback that receives a complete file (the file, its name, its type and 
its metadata) instead of a `FileUpload`.
   
   ### The Wicket adapter in wicket-extensions, with the same public API as now
   
   - `ResumableUploadResource` adapts `WebRequest` and `WebResponse` to the 
protocol handler.
   - `ResumableUploadResourceReference` does the following:
     - mounts the resource;
     - takes `getCurrentOwner()` from the session;
     - connects the end of the session and the stop of the application to the 
registry;
     - hands a complete file to the `IUploadsFileManager`.
   - `HmacGrantSigner.inSession()` and `CryptFactoryGrantSigner`.
   - `ResumableUploadToResourceField` and its script. The script builds on 
`Wicket.FileUploadToResourceField`, so it stays Wicket's. Other projects can 
already use any tus client, with a query from 
`ResumableUploadResourceReference.newQuery()`.
   
   ## Open questions
   
   - Where should the core live? It could be a package of wicket-extensions 
that a test keeps free of Wicket imports, a module of its own, or a project 
outside Wicket.
   - Should the core use the servlet API, or a small request and response 
interface of its own? The interface would also fit servers that are not servlet 
containers.
   - Should the core use `IClusterable`, `Bytes` and `Args` from wicket-util, 
which does not depend on wicket-core, or only the JDK?
   - tus-java-server already exists. Should Wicket reuse it rather than keep a 
core of its own? The PRs avoided adding a dependency.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to