aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/com
diff options
context:
space:
mode:
authorKostya <mail@sartin.in>2026-10-10 14:12:55 +0300
committerKostya <mail@sartin.in>2026-10-10 14:13:20 +0300
commit6f0ab9c9a20b96890ed60bc168b28d29f5db39e5 (patch)
tree51b85eab9c6b9995b8836544f54ddae861b18b06 /src/test/java/com
parent33d313e17b841db3736c465447913df0cc73d5df (diff)
downloadguess-market-6f0ab9c9a20b96890ed60bc168b28d29f5db39e5.tar.gz
guess-market-6f0ab9c9a20b96890ed60bc168b28d29f5db39e5.tar.xz
guess-market-6f0ab9c9a20b96890ed60bc168b28d29f5db39e5.zip
server: accept event file uploads held entirely in memory
Add POST /api/upload: a logged-in user sends a Schema v3 file as a multipart part, its events join the market for everyone, and the uploader becomes their Market Maker. It uses the Servlet API's own multipart support, as the spec asks, and hands the part's stream to the v3 loader, so validation errors (bad XML, broken Exercise 1 rules, a name already in the market) come back as 400 with their reason. As in Exercise 1, a file whose name does not end in .xml is refused before it is read, since a request need not come from our client. The spec warns that the grading server cannot write files, and Tomcat writes any multipart part larger than @MultipartConfig's fileSizeThreshold to a temp file. That threshold defaults to 0, so a plain upload servlet always touches the disk. Cap uploads at 1 MB and put the threshold above the whole request limit, so every upload stays in memory. Bigger files get 413, requests without a session 401, and non-multipart bodies 400. Tomcat deletes spooled parts once the request ends, so comparing the files before and after an upload cannot catch spooling. The test instead watches the webapp's temp directory for any file being created while a near-limit upload runs. It fails if the threshold is set back to 0.
Diffstat (limited to 'src/test/java/com')
0 files changed, 0 insertions, 0 deletions